OLD | NEW |
| (Empty) |
1 <html> | |
2 <body> | |
3 <div id="player_container"></div> | |
4 <script> | |
5 var player = null; | |
6 function InstallEventHandler(event, action) { | |
7 player.addEventListener(event, function(e) { | |
8 eval(action); | |
9 }, false); | |
10 } | |
11 | |
12 // Parse the location and load the media file accordingly. | |
13 var url = window.location.href; | |
14 var url_parts = url.split('?'); | |
15 | |
16 // Make sure the URL is of the form "player.html?query". | |
17 var ok = false; | |
18 if (url_parts.length > 1) { | |
19 var query = url_parts[1]; | |
20 var query_parts = query.split('='); | |
21 if (query_parts.length == 2) { | |
22 var tag = query_parts[0]; | |
23 var media_url = query_parts[1]; | |
24 if (tag == 'audio' || tag == 'video') { | |
25 ok = true; | |
26 var container = document.getElementById('player_container'); | |
27 container.innerHTML = '<' + tag + ' controls id="player"></' + tag + '>'; | |
28 player = document.getElementById('player'); | |
29 | |
30 // Install event handlers. | |
31 InstallEventHandler('error', 'document.title = "ERROR"'); | |
32 InstallEventHandler('playing', 'document.title = "PLAYING"'); | |
33 | |
34 // Starts the player. | |
35 player.src = media_url; | |
36 player.play(); | |
37 } | |
38 } | |
39 } | |
40 if (!ok) { | |
41 document.title = 'FAILED'; | |
42 } | |
43 </script> | |
44 </body> | |
45 </html> | |
OLD | NEW |