如果使用者的偏好沒有指示另一條軌道更適合 HTML,如何確定要啟用該軌道?


如果您為影片提供了兩個字幕軌道,請使用 default 屬性來標識要啟用的軌道。

示例

您可以嘗試以下程式碼來實現軌道的 default 屬性 -

<!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-03-2020

65 次觀看

啟動你的 事業

透過完成該課程獲得認證

開始
廣告
© . All rights reserved.