Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / test / data / mse_different_containers.html
blobae9c8a3bb580dd021416802bc5286f7c19b8abc9
1 <html>
2 <head>
3 <title>Test media source playback with different containers.</title>
4 </head>
5 <body onload="runTest();">
6 <video></video>
7 <script src='eme_player_js/app_loader.js' type='text/javascript'></script>
8 <script type="text/javascript">
9 // Specify possible content for clear and encrypted streams in both MP4
10 // and WEBM format. For testing we don't care if the audio matches the
11 // video or if the length of each container is the same.
12 var VIDEO_MP4_MEDIA_TYPE = 'video/mp4; codecs="avc1.4D4041"';
13 var VIDEO_WEBM_MEDIA_TYPE = 'video/webm; codecs="vp8"';
14 var VIDEO_MP4_CLEAR_FILE = 'bear-640x360-v_frag.mp4';
15 var VIDEO_WEBM_CLEAR_FILE = 'bear-320x240-video-only.webm';
16 var VIDEO_MP4_ENCRYPTED_FILE = 'bear-640x360-v_frag-cenc.mp4';
17 var VIDEO_WEBM_ENCRYPTED_FILE = 'bear-320x240-v_enc-v.webm';
19 var AUDIO_MP4_MEDIA_TYPE = 'audio/mp4; codecs="mp4a.40.2"';
20 var AUDIO_WEBM_MEDIA_TYPE = 'audio/webm; codecs="vorbis"';
21 var AUDIO_MP4_CLEAR_FILE = 'bear-640x360-a_frag.mp4';
22 var AUDIO_WEBM_CLEAR_FILE = 'bear-320x240-audio-only.webm';
23 var AUDIO_MP4_ENCRYPTED_FILE = 'bear-640x360-a_frag-cenc.mp4';
24 var AUDIO_WEBM_ENCRYPTED_FILE = 'bear-a_enc-a.webm';
26 var media_types = [];
27 var media_files = [];
29 // The time in secs to play the streams.
30 var PLAY_TIME_SEC = 0.1;
32 var video = document.querySelector('video');
34 function onTimeUpdate() {
35 if (video.currentTime < PLAY_TIME_SEC)
36 return;
38 video.removeEventListener('timeupdate', onTimeUpdate);
39 video.removeEventListener('ended', Utils.failTest);
40 Utils.installTitleEventHandler(video, 'ended');
42 // Seek to end to save test execution time.
43 video.currentTime = 1000;
46 function addVideoStream(format) {
47 if (format == 'CLEAR_MP4') {
48 media_types = media_types.concat(VIDEO_MP4_MEDIA_TYPE);
49 media_files = media_files.concat(VIDEO_MP4_CLEAR_FILE);
50 } else if (format == 'CLEAR_WEBM') {
51 media_types = media_types.concat(VIDEO_WEBM_MEDIA_TYPE);
52 media_files = media_files.concat(VIDEO_WEBM_CLEAR_FILE);
53 } else if (format == 'ENCRYPTED_MP4') {
54 media_types = media_types.concat(VIDEO_MP4_MEDIA_TYPE);
55 media_files = media_files.concat(VIDEO_MP4_ENCRYPTED_FILE);
56 } else if (format == 'ENCRYPTED_WEBM') {
57 media_types = media_types.concat(VIDEO_WEBM_MEDIA_TYPE);
58 media_files = media_files.concat(VIDEO_WEBM_ENCRYPTED_FILE);
59 } else {
60 Utils.failTest('Unrecognized video type.');
64 function addAudioStream(format) {
65 if (format == 'CLEAR_MP4') {
66 media_types = media_types.concat(AUDIO_MP4_MEDIA_TYPE);
67 media_files = media_files.concat(AUDIO_MP4_CLEAR_FILE);
68 } else if (format == 'CLEAR_WEBM') {
69 media_types = media_types.concat(AUDIO_WEBM_MEDIA_TYPE);
70 media_files = media_files.concat(AUDIO_WEBM_CLEAR_FILE);
71 } else if (format == 'ENCRYPTED_MP4') {
72 media_types = media_types.concat(AUDIO_MP4_MEDIA_TYPE);
73 media_files = media_files.concat(AUDIO_MP4_ENCRYPTED_FILE);
74 } else if (format == 'ENCRYPTED_WEBM') {
75 media_types = media_types.concat(AUDIO_WEBM_MEDIA_TYPE);
76 media_files = media_files.concat(AUDIO_WEBM_ENCRYPTED_FILE);
77 } else {
78 Utils.failTest('Unrecognized audio type.');
82 function runTest() {
83 video.addEventListener('timeupdate', onTimeUpdate);
84 video.addEventListener('ended', Utils.failTest);
86 var testConfig = new TestConfig();
87 testConfig.loadQueryParams();
88 addVideoStream(testConfig.videoFormat);
89 addAudioStream(testConfig.audioFormat);
91 var mediaSource =
92 MediaSourceUtils.loadMediaSource(media_files, media_types);
94 if (testConfig.runEncrypted > 0) {
95 var emePlayer = PlayerUtils.createPlayer(video, testConfig);
96 emePlayer.registerEventListeners()
97 .then(function(player) {
98 video.src = window.URL.createObjectURL(mediaSource);
100 .catch(function(error) {
101 Utils.failTest('Unable to register EME event listeners.');
103 } else {
104 video.src = window.URL.createObjectURL(mediaSource);
106 video.play();
108 </script>
109 </body>
110 </html>