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
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68

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

<html>
  <head>
    <title>Test media source playback with different containers.</title>
  </head>
  <body onload="runTest();">
    <video></video>
    <script src='eme_player_js/app_loader.js' type='text/javascript'></script>
    <script type="text/javascript">

      // The time in secs to play the streams. Several encrypted streams have
      // 1/2 second clear leads, so play at least a second to ensure that the
      // encrypted content is handled.
      var PLAY_TIME_SEC = 1.0;

      var video = document.querySelector('video');

      function onTimeUpdate() {
        Utils.timeLog('timeupdate @ ' + video.currentTime);
        if (video.currentTime < PLAY_TIME_SEC)
          return;

        video.removeEventListener('timeupdate', onTimeUpdate);
        video.removeEventListener('ended', Utils.failTest);
        Utils.installTitleEventHandler(video, 'ended');

        // Seek to end to save test execution time. Most of the test videos
        // (e.g. the bear videos) are about 2.5 seconds long.
        video.currentTime = 3000;
      }

      function runTest() {
        video.addEventListener('timeupdate', onTimeUpdate);
        video.addEventListener('ended', Utils.failTest);

        var testConfig = new TestConfig();
        testConfig.loadQueryParams();

        var media_types = [];
        var media_files = [];
        if (testConfig.videoFormat) {
          media_types = media_types.concat(testConfig.videoFormat);
          media_files = media_files.concat(testConfig.videoFile);
        }
        if (testConfig.audioFormat) {
          media_types = media_types.concat(testConfig.audioFormat);
          media_files = media_files.concat(testConfig.audioFile);
        }

        var mediaSource =
            MediaSourceUtils.loadMediaSource(media_files, media_types);

        if (testConfig.runEncrypted > 0) {
          var emePlayer = PlayerUtils.createPlayer(video, testConfig);
          emePlayer.registerEventListeners()
              .then(function(player) {
                video.src = window.URL.createObjectURL(mediaSource);
              })
              .catch(function(error) {
                Utils.failTest('Unable to register EME event listeners.');
              });
        } else {
          video.src = window.URL.createObjectURL(mediaSource);
        }
        video.play();
      }
      </script>
  </body>
</html>