Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: media/test/data/player.html

Issue 2360443002: [Chromecast] Add CastMediaBlocker and BrowserTest (Closed)
Patch Set: Fix double stop bug Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <body onload="RunTest();"> 2 <body onload="RunTest();">
3 <div id="player_container"></div> 3 <div id="player_container"></div>
4 </body> 4 </body>
5 5
6 <script type="text/javascript"> 6 <script type="text/javascript">
7 // <audio> or <video> player element. 7 // <audio> or <video> player element.
8 var player; 8 var player;
9 9
10 // Listen for |event| from |element|, set document.title = |event| upon event. 10 // Listen for |event| from |element|, set document.title = |event| upon event.
(...skipping 29 matching lines...) Expand all
40 // Uses URL query parameters to create an audio or video element using a given 40 // Uses URL query parameters to create an audio or video element using a given
41 // source. URL must be of the form "player.html?[tag]=[media_url]". Plays the 41 // source. URL must be of the form "player.html?[tag]=[media_url]". Plays the
42 // media and waits for X seconds of playback or the ended event, at which point 42 // media and waits for X seconds of playback or the ended event, at which point
43 // the test seeks near the end of the file and resumes playback. Test completes 43 // the test seeks near the end of the file and resumes playback. Test completes
44 // when the second ended event occurs or an error event occurs at any time. 44 // when the second ended event occurs or an error event occurs at any time.
45 function RunTest() { 45 function RunTest() {
46 var url_parts = window.location.href.split('?'); 46 var url_parts = window.location.href.split('?');
47 if (url_parts.length != 2) 47 if (url_parts.length != 2)
48 return Failed(); 48 return Failed();
49 49
50 var query_parts = url_parts[1].split('='); 50 var tag = '';
51 if (query_parts.length != 2) 51 var media_url = '';
52 var loop = false;
53
54 var query_params = url_parts[1].split('&');
55 for (var query_param in query_params) {
56 var query_parts = query_params[query_param].split('=');
57 if (query_parts.length != 2) {
58 return Failed();
59 }
60
61 if (query_parts[0] == 'audio' || query_parts[0] == 'video') {
62 tag = query_parts[0];
63 media_url = query_parts[1];
64 continue;
65 }
66
67 if (query_parts[0] == 'loop') {
68 loop = (query_parts[1] == 'true');
69 continue;
70 }
71 }
72
73 if (tag != 'audio' && tag != 'video') {
52 return Failed(); 74 return Failed();
53 75 }
xhwang 2016/09/21 21:33:18 Could you please update the comment above this fun
derekjchow1 2016/09/21 22:06:12 Done.
54 var tag = query_parts[0];
55 var media_url = query_parts[1];
56 if (tag != 'audio' && tag != 'video')
57 return Failed();
58 76
59 // Create player and insert into DOM. 77 // Create player and insert into DOM.
60 player = document.createElement(tag); 78 player = document.createElement(tag);
61 player.controls = true; 79 player.controls = true;
62 document.getElementById('player_container').appendChild(player); 80 document.getElementById('player_container').appendChild(player);
63 81
64 player.addEventListener('loadedmetadata', function(e) { 82 player.addEventListener('loadedmetadata', function(e) {
65 document.title = '' + player.videoWidth + ' ' + player.videoHeight; 83 document.title = '' + player.videoWidth + ' ' + player.videoHeight;
66 }); 84 });
67 85
68 // Transition to the seek test after X seconds of playback or when the ended 86 // Transition to the seek test after X seconds of playback or when the ended
69 // event occurs, whichever happens first. 87 // event occurs, whichever happens first.
70 player.addEventListener('ended', SeekTestStep, false); 88 player.addEventListener('ended', SeekTestStep, false);
71 player.addEventListener('timeupdate', SeekTestTimeoutSetup, false); 89 player.addEventListener('timeupdate', SeekTestTimeoutSetup, false);
72 90
73 // Ensure we percolate up any error events. 91 // Ensure we percolate up any error events.
74 InstallTitleEventHandler(player, 'error'); 92 InstallTitleEventHandler(player, 'error');
75 93
76 // Starts the player. 94 // Starts the player.
95 player.loop = loop;
77 player.src = media_url; 96 player.src = media_url;
78 player.play(); 97 player.play();
79 } 98 }
80 </script> 99 </script>
81 </html> 100 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698