html5在屏幕上显示track信息

work24 分享于 昨天 1689阅 0人收藏此代码, 我要收藏

html5在屏幕上显示track信息

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Working with Tracks</title>
  <style>
    #player, #info{
      float: left;
    }
  </style>
  <script>
    function initiate(){
      var list = "";
      var info = document.getElementById('info');
      var mytrack = document.getElementById('mytrack');
      var obj = mytrack.track;
 
      list += "<br>Kind: " + obj.kind;
      list += "<br>Label: " + obj.label;
      list += "<br>Language: " + obj.language;
      info.innerHTML = list;
    }
    addEventListener('load', initiate);
  </script>
</head>
<body>
  <section id="player">
    <video id="media" width="720" height="400" controls>
      <source src="trailer.mp4">
      <source src="trailer.ogg">
      <track id="mytrack" label="English Subtitles" src="subtitles.vtt" srclang="en" default>
    </video>
  </section>
  <aside id="info"></aside>
</body>
</html>
<!--该代码片段来自于: http://www.sharejs.com/codes/html/8312-->

标签:
  • track
  • html5
  • video