如何在 HTML 中指定文字軌道的型別?


使用 HTML 中的 kind 屬性來指定 HTML 中文字軌道的型別。例如,你可以將字幕檔案中的字幕作為型別設定。

示例

你可以嘗試執行以下程式碼來實現 kind 屬性 -

<!DOCTYPE HTML>
<html>
   <body>

      <video width = "300" height="200" controls autoplay>
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         <source src = "/html5/foo.mp4" type = "video/mp4" />
         <track src = "subtitles_en.vtt" kind = "subtitles" srclang = "en" label = "English">
         <track src = "subtitles_ru.vtt" kind = "subtitles" srclang = "ru" label = "Russia" default>
         Your browser does not support the video element.
      </video>

   </body>
</html>

更新於: 03-Mar-2020

97 人檢視

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告