-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
74 lines (67 loc) · 2.22 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("jquery", "1.7.1")
google.load("swfobject", "2.2");
</script>
<script type="text/javascript">
$(document).ready(function(){
var socket = io.connect("http://localhost:8080");
var ytplayer = null;
var currentVideo = null;
socket.emit("get_id", function(id){
$("#screen-id").text("Screen ID: " + id);
});
socket.on("msg", function(data){
if(data.action === "play") {
if(currentVideo === null || data.value !== currentVideo) {
currentVideo = data.value;
loadVideo(data.value);
}
}
});
});
// Loads the selected video into the player.
function loadVideo(videoID) {
if(ytplayer) {
ytplayer.loadVideoById(videoID);
}
}
// This function is called when an error is thrown by the player
function onPlayerError(errorCode) {
alert("An error occured of type:" + errorCode);
}
// This function is automatically called by the player once it loads
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("ytPlayer");
ytplayer.addEventListener("onError", "onPlayerError");
}
// The "main method" of this sample. Called when someone clicks "Run".
function loadPlayer() {
// The video to load
var videoID = "ylLzyHk54Z0"
// Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always" };
// The element id of the Flash embed
var atts = { id: "ytPlayer" };
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/v/" + videoID +
"?version=3&enablejsapi=1&playerapiid=player1",
"videoDiv", "480", "295", "9", null, null, params, atts);
}
function _run() {
loadPlayer();
}
google.setOnLoadCallback(_run);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div class="wrapper">
<div id="screen-id"></div>
<div id="now-playing"></div>
<div id="videoDiv">Loading...</div>
</div>
</body>
</html>