| 7272 |
amit.gupta |
1 |
/*
|
|
|
2 |
* Chromeless player has no controls.
|
|
|
3 |
*/
|
|
|
4 |
|
|
|
5 |
// Update a particular HTML element with a new value
|
|
|
6 |
function updateHTML(elmId, value) {
|
|
|
7 |
document.getElementById(elmId).innerHTML = value;
|
|
|
8 |
}
|
|
|
9 |
|
|
|
10 |
// This function is called when an error is thrown by the player
|
|
|
11 |
function onPlayerError(errorCode) {
|
|
|
12 |
alert("An error occured of type:" + errorCode);
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
// This function is called when the player changes state
|
|
|
16 |
function onPlayerStateChange(newState) {
|
|
|
17 |
updateHTML("playerState", newState);
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
// This function is automatically called by the player once it loads
|
|
|
23 |
function onYouTubePlayerReady(playerId) {
|
|
|
24 |
if(playerId == "ytPlayer1") {
|
|
|
25 |
ytplayer = document.getElementById("ytPlayer");
|
|
|
26 |
// This causes the updatePlayerInfo function to be called every 250ms to
|
|
|
27 |
// get fresh data from the player
|
|
|
28 |
//setInterval(updatePlayerInfo, 250);
|
|
|
29 |
//updatePlayerInfo();
|
|
|
30 |
// ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
|
|
|
31 |
// ytplayer.addEventListener("onError", "onPlayerError");
|
|
|
32 |
//Load an initial video into the player
|
|
|
33 |
ytplayer.cueVideoById("dceW9l72mTE");
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
else if(playerId == "ytPlayer2") {
|
|
|
37 |
ytplayer = document.getElementById("ytPlayer");
|
|
|
38 |
// This causes the updatePlayerInfo function to be called every 250ms to
|
|
|
39 |
// get fresh data from the player
|
|
|
40 |
//setInterval(updatePlayerInfo, 250);
|
|
|
41 |
//updatePlayerInfo();
|
|
|
42 |
// ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
|
|
|
43 |
// ytplayer.addEventListener("onError", "onPlayerError");
|
|
|
44 |
//Load an initial video into the player
|
|
|
45 |
ytplayer.cueVideoById("ylLzyHk54Z0");
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
// The "main method" of this sample. Called when someone clicks "Run".
|
|
|
50 |
function loadPlayer() {
|
|
|
51 |
// Lets Flash from another domain call JavaScript
|
|
|
52 |
var params = { allowScriptAccess: "always" };
|
|
|
53 |
// The element id of the Flash embed
|
|
|
54 |
var atts = { id: "ytPlayer" };
|
|
|
55 |
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
|
|
|
56 |
swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
|
|
|
57 |
"&enablejsapi=1&playerapiid=ytplayer1",
|
|
|
58 |
"videoDiv1", "205", "275", "8", null, null, params, atts);
|
|
|
59 |
|
|
|
60 |
swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
|
|
|
61 |
"&enablejsapi=1&playerapiid=ytplayer2",
|
|
|
62 |
"videoDiv2", "205", "275", "8", null, null, params, atts);
|
|
|
63 |
|
|
|
64 |
}
|
|
|
65 |
function _run() {
|
|
|
66 |
loadPlayer();
|
|
|
67 |
}
|