- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / media / youtube.html
1 <!-- This is a test html file for Youtube video tests -->
2 <html>
3
4 <script type="text/javascript" src="swfobject.js"></script>   
5 <script type="text/javascript">
6
7 // Most of this was borrowed from:
8 // http://code.google.com/apis/ajax/playground/?exp=youtube#polling_the_player
9
10 // Update a particular HTML element with a new value
11 function updateHTML(elmId, value) {
12   document.getElementById(elmId).innerHTML = value;
13 }
14
15 // This function is called when the player changes state
16 function onPlayerStateChange(newState) {
17   updateHTML("playerState", newState);
18 }
19
20 // Display information about the current state of the player
21 function updatePlayerInfo() {
22   if(ytplayer && ytplayer.getDuration) {
23     updateHTML("bytesTotal", ytplayer.getVideoBytesTotal());
24     updateHTML("startBytes", ytplayer.getVideoStartBytes());
25     updateHTML("bytesLoaded", ytplayer.getVideoBytesLoaded());
26     updateHTML("duration", ytplayer.getDuration());
27     updateHTML("videoCurrentTime", ytplayer.getCurrentTime());
28   }
29 }
30
31 function onYouTubePlayerReady(playerId) {
32     ytplayer = document.getElementById("myytplayer");
33     console.log("player ready to play");
34     setInterval(updatePlayerInfo, 1000);
35     updatePlayerInfo();
36     // Possible player statuses:
37     // unstarted (-1), ended (0), playing (1), paused (2), buffering (3),
38     // video cued (5).
39     updateHTML("playerState", ytplayer.getPlayerState());
40     ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
41     ytplayer.addEventListener("onError", "onPlayerError");
42 }
43
44 function loadPlayer() {
45   var params = { allowScriptAccess: "always" };
46   var atts = { id: "myytplayer" };
47   var video_id = window.location.href.split("video=");
48   swfobject.embedSWF(
49     "http://www.youtube.com/e/" + video_id[1] +
50       "?version=3&enablejsapi=1&playerapiid=ytplayer",
51     "ytapiplayer", "800", "600", "8", null, null, params, atts);
52 }
53
54 </script>
55  
56 <div id="ytapiplayer"> 
57   You need Flash player 8+ and JavaScript enabled to view this video. 
58 </div>
59 <body onload="loadPlayer()">
60 <br>
61 Player State (playerState):  <span id=playerState>0</span>  Possible player
62 statuses: unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
63 <br>
64 Total Bytes (bytesTotal): <span id=bytesTotal>0</span>
65 <br>
66 Start Bytes (startBytes): <span id=startBytes>0</span>
67 <br>
68 Bytes Loaded (bytesLoaded): <span id=bytesLoaded>1</span>
69 <br>
70 Duration (duration): <span id=duration>0</span>
71 <br>
72 Current Time (videoCurrentTime): <span id=videoCurrentTime>0</span>
73
74 </html>