1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47

media / test / data / rapid_video_change_test.html [blame]

<!DOCTYPE html>
<html>
  <head>
    <title>HTML 5 Change H.264 Video Test</title>
    <script>
      var changeVideoInterval;
      var changeVideoCounter = 0;

      function changeVideo() {
        try {
          if (changeVideoCounter == 40) {
            alert('40 video changes done. Test over');
            window.clearInterval(changeVideoInterval);
            return;
          }
          var video = document.getElementById('video');
          video.pause();
          video.src = 'bear-1280x720.mp4?counter=' +
              changeVideoCounter.toString();
          ++changeVideoCounter;
          video.play();
          video.currentTime = 1;
        }

        catch (e) {
        }
      }

      function onLoad() {
        var video = document.getElementById('video');
        video.play();
        video.currentTime = 1;
        changeVideoInterval = setInterval(changeVideo, 200);
      }
    </script>
  </head>
  
  <body onload='onLoad();'> <b> This test tests the case where in H.264 H/W
   decoded videos are added and removed a number of times from the page,
   while they are playing. <br> This should not cause the browser to hang.
   <div id='videoDiv'>
     <video id='video' width=320 height=240 src='bear-1280x720.mp4'
       controls='controls'>
     </video>
   </div>
  </body>
</html>