Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <title>Metadata track driven slideshow</title>
  5.     <style type="text/css">
  6.       #slideshow
  7.       {
  8.         /* set the iframe dimensions large enough to see */  
  9.         width:100%;
  10.         height:400px;
  11.       }      
  12.     </style>
  13.     <script type="text/javascript">
  14.       document.addEventListener("DOMContentLoaded", function () {  // don't run this until all DOM content is loaded
  15.         var tracks = document.getElementById("video1").textTracks;
  16.         // Set the metadata track to be active
  17.         tracks[1].mode = tracks[1].SHOWING;  // Make sure it's active
  18.         var track2 = document.getElementById("control1"); // get the track object to add an event to
  19.        
  20.         //  This is the main event that drives the slide show
  21.         track2.addEventListener("cuechange", function () {          
  22.           var myCues = this.track.activeCues;   // get an array of current cues.
  23.           if (myCues.length > 0) {              // test to be sure there's cues
  24.             document.getElementById("slideshow").src = myCues[0].text;  // get the text part of the cue (URL)
  25.             // build an anchor tag and set it to the innerHTML of the span tag
  26.             document.getElementById("currentURL").innerHTML = "<a href='" + myCues[0].text + "' target='_blank' >" + myCues[0].text + "</a>";
  27.           }
  28.         }, false);
  29.       }, false);      
  30. </script>
  31. </head>
  32.   <body>
  33.     <video id="video1" autoplay controls>
  34.       <source src="http://ie.microsoft.com/testdrive/Videos/BehindIE9ModernWebStandards/Video.mp4" type="video/mp4"/>
  35.       <track id="track1" label="English captions" src="entrack.vtt" kind="subtitles" srclang="en" default >    
  36.       <track id="control1" label="command track" src="control1.vtt" kind="metadata">
  37.     </video>
  38.     <div>URL: <span id="currentURL"></span></div>
  39.     <iframe id="slideshow" ></iframe>
  40.   </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement