Index: media/test/data/player.html |
diff --git a/media/test/data/player.html b/media/test/data/player.html |
index fa50d731e1a3610e1f9db825f5cb6f104bb072df..4f8b51086f073b3b2fe475edd2b29c593cb8ff2f 100644 |
--- a/media/test/data/player.html |
+++ b/media/test/data/player.html |
@@ -38,23 +38,46 @@ function SeekTestTimeoutSetup() { |
} |
// Uses URL query parameters to create an audio or video element using a given |
-// source. URL must be of the form "player.html?[tag]=[media_url]". Plays the |
-// media and waits for X seconds of playback or the ended event, at which point |
-// the test seeks near the end of the file and resumes playback. Test completes |
-// when the second ended event occurs or an error event occurs at any time. |
+// source. URL must be of the form: |
+// "player.html?[tag]=[media_url](&loop=[true/false])". |
xhwang
2016/09/22 21:42:37
nit: typically we use [] for optional parameters.
derekjchow1
2016/09/22 23:00:01
Done.
|
+// |
+// Plays the media and waits for X seconds of playback or the ended event, at |
+// which point the test seeks near the end of the file and resumes playback. |
+// Test completes when the second ended event occurs or an error event occurs at |
+// any time. |
+// There is an optional loop query parameter which when set to true, will cause |
+// the created media element to loop. |
function RunTest() { |
var url_parts = window.location.href.split('?'); |
if (url_parts.length != 2) |
return Failed(); |
- var query_parts = url_parts[1].split('='); |
- if (query_parts.length != 2) |
- return Failed(); |
- |
- var tag = query_parts[0]; |
- var media_url = query_parts[1]; |
- if (tag != 'audio' && tag != 'video') |
+ var tag = ''; |
+ var media_url = ''; |
+ var loop = false; |
+ |
+ var query_params = url_parts[1].split('&'); |
+ for (var query_param in query_params) { |
+ var query_parts = query_params[query_param].split('='); |
+ if (query_parts.length != 2) { |
+ return Failed(); |
+ } |
+ |
+ if (query_parts[0] == 'audio' || query_parts[0] == 'video') { |
+ tag = query_parts[0]; |
+ media_url = query_parts[1]; |
+ continue; |
+ } |
+ |
+ if (query_parts[0] == 'loop') { |
+ loop = (query_parts[1] == 'true'); |
+ continue; |
+ } |
+ } |
+ |
+ if (tag != 'audio' && tag != 'video') { |
return Failed(); |
+ } |
// Create player and insert into DOM. |
player = document.createElement(tag); |
@@ -74,6 +97,7 @@ function RunTest() { |
InstallTitleEventHandler(player, 'error'); |
// Starts the player. |
+ player.loop = loop; |
player.src = media_url; |
player.play(); |
} |