-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.html
executable file
·249 lines (217 loc) · 9.44 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Channel of Awesome</title>
<meta name="description" content="Channel of Awesome - Create playlists of YouTube and Vimeo videos that play fullscreen in a loop">
<link rel="shortcut icon" href="favicon.ico">
<link rel="apple-touch-icon" href="icon.png">
<!-- Facebook sharing. http://developers.facebook.com/docs/opengraph/ -->
<meta property="og:site_name" content="Channel Of Awesome" />
<meta property="og:title" content="Channel Of Awesome" />
<meta property="og:description" content="Create playlists of YouTube and Vimeo videos that play fullscreen in a loop" />
<meta property="og:image" content="http://dfcb.github.com/channel-of-awesome/icon.png" />
<style>
/* DIN Font is NOT open source. Licensed for Draftfcb use only.
To obtain a license, purchase from fontfont.com */
@font-face {font-family: DINWeb;src: url("fonts/DINWeb.eot");}
@font-face {font-family: DINWeb;src: url("fonts/DINWeb.woff") format("woff");}
@font-face {font-family: DINWeb-Bold;src: url("fonts/DINWeb-Bold.eot");}
@font-face {font-family: DINWeb-Bold;src: url("fonts/DINWeb-Bold.woff") format("woff");}
body { background:#000;margin:0; padding: 0; overflow: hidden; font-family: DINWeb, sans-serif; font-size: 18px; }
.wrapper { width:100%; height:100%; }
.hide { display: none; }
#intro { position: absolute; top: 120px; left: 30%; width: 36%; background: #111; background:rgba(0,0,0,.8); color: #fff; padding: 0 2% 15px; cursor: pointer; }
h1 { font-family: DINWeb-Bold; font-weight: normal; text-transform: uppercase; margin: 20px 0 0; }
p { margin:0 0 10px; }
small { font-style: italic; }
a, a:hover, a:visited { color: #999; font-family: DINWeb-Bold; font-style: italic; }
.author { line-height: 1; margin-top: 20px; }
.btn-close { text-decoration: none; color: #fff; position: absolute; top: 0; right: 10px; font-size: 1.5em; font-family: DINWeb-Bold; font-style: normal; }
</style>
</head>
<body>
<div id="intro" onclick="document.body.removeChild(document.getElementById('intro'))">
<h1>Channel of Awesome</h1>
<p>Hit → to go to the next video.</p>
<p>Make your <a href="https://github.com/dfcb/channel-of-awesome#readme">own Channel of Awesome</a> from videos you find on YouTube and Vimeo. Go to the <a href="https://github.com/dfcb/channel-of-awesome">project page</a> to find out more.</p>
<p class="author"><small>Channel of Awesome is an <a href="https://github.com/dfcb/channel-of-awesome" target="_blank">open source project</a> by <a href="http://twitter.com/johnpolacek" target="_blank">@johnpolacek</a> of the <a href="http://dfcb.github.com" target="_blank">dev group</a> at draftfcb chicago</small></p>
<a href="#" class="btn-close">×</a>
</div>
<div class="wrapper">
<div id="yt-player-contain" class="hide"></div>
<div id="v-player-contain" class="hide"></div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="//www.youtube.com/iframe_api"></script>
<script src="http://a.vimeocdn.com/js/froogaloop2.min.js?462b5-1349886067"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34145020-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script>
// add arrays to playlists for different awesome channels
// for example, add cats:[...] then load it by going to index.html#cats
var playlists = {
tech:[
'youtube:c3-wIICjAhE',
'youtube:Llmq2hYWXHo',
'vimeo:31946199',
'vimeo:46857169',
'youtube:6vN57XseOpw',
'vimeo:44369414',
'youtube:HlPrOypwt-w',
'youtube:gvd95Z6AiuM',
'youtube:H5yT9FL-2v4',
'youtube:YvbAqw0sk6M',
'vimeo:47095462',
'vimeo:8525186',
'youtube:rZslQZ6iMgA',
'vimeo:45417241',
'youtube:DRRu5dKRfTU',
'youtube:JXmBrD4b4EI',
'youtube:cseTX_rW3uM',
'youtube:tu0TRA6a21Q',
'vimeo:48362240',
'youtube:Y7-UjTKygO0',
'youtube:PlHUOHr4WxA',
'youtube:akA-B64RACU',
'vimeo:34824490',
'youtube:_uTJiEYI1ik',
'vimeo:42846180',
'youtube:_d6KuiuteIA',
'youtube:NDqNqF15SWs',
'vimeo:2229299',
'vimeo:44904580',
'vimeo:28176347',
'youtube:O2udM5dGT-w',
'youtube:58dsqozft3k',
'youtube:2hASOre63Nk',
'youtube:E-pyay3v3Qo',
'youtube:XLKKbz2mNyo',
'vimeo:44464000',
'vimeo:30780208',
'vimeo:2177723',
'vimeo:45276780',
'youtube:3TOrj-GadtU'
]
}
// get playlist id or array from hash, if it isn't valid use default, then randomize
var defaultPlaylist = 'tech';
var playlist;
if (location.hash === '') {
playlist = playlists[defaultPlaylist];
} else if (location.hash.indexOf(',') !== -1) {
playlist = location.hash.substr(1).split(',');
} else {
playlist = playlists[location.hash.substr(1)] || playlists[defaultPlaylist];
}
playlist.sort(function() { return 0.5 - Math.random() });
var ytPlayer,
vPlayer,
vidIndex = 0;
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
}
else {
element.attachEvent('on' + eventName, callback);
}
}
function onYouTubeIframeAPIReady() {
ytPlayer = new YT.Player('yt-player-contain', {
height: '100%',
width: '100%',
playerVars: {
controls:0,
showinfo:0
},
events: {
'onReady': onYTPlayerReady,
'onStateChange': onYTPlayerStateChange
}
});
}
function onYTPlayerReady(e) {
playNextVideo();
}
function playNextVideo() {
var ytPlayerContainer = document.getElementById('yt-player-contain')
var vPlayerContainer = document.getElementById('v-player-contain')
// get next video from playlist
var video = playlist[vidIndex].split(':');
// increment video playlist index
vidIndex = (vidIndex === playlist.length) ? 0 : vidIndex+1;
// get video data
var service = video[0];
var id = video[1];
var startTime = (video[2] === undefined) ? 0 : video[2];
// track video view
_gaq.push(['_trackPageview', '/'+service+'/'+id]);
// update player with new video
if (service === 'youtube') {
// hide vimeo
vPlayerContainer.className = 'hide';
vPlayerContainer.innerHTML = '';
// show/load/play video
ytPlayerContainer.className = '';
ytPlayer.loadVideoById(id, startTime);
}
else if (service === 'vimeo') {
// hide youtube
ytPlayerContainer.className = 'hide';
// show/load/play vimeo
vPlayerContainer.className = '';
vPlayerContainer.innerHTML = '<iframe id="v-player" src="http://player.vimeo.com/video/'+id+'?api=1&player_id=v-player&autoplay=1&title=0&byline=0&portrait=0&api=1" width="100%" height="100%" frameborder="0" webkitallowfullscreen allowfullscreen></iframe>';
vPlayer = document.getElementById('v-player');
$f(vPlayer).addEvent('ready', function(playerID) {
vPlayer = $f(playerID);
vPlayer.addEvent('finish', playNextVideo);
vPlayer.api('seekTo', startTime);
});
var isPlaying = false;
$f(vPlayer).addEvent('playProgress', function(playerID) {
isPlaying = true;
});
setTimeout(function() {
if (!isPlaying) {
onPlayError('Could not play video, Vimeo ID:'+id);
playNextVideo();
}
}, 5000)
}
// if service not supported error
else {
onPlayError('Video service "'+service+'" not recognized');
}
}
function onPlayError(msg) {
// throw error and try next video
throw new Error(msg);
playNextVideo();
}
function onYTPlayerStateChange(e) {
// play next video when video ends
if (e.data === YT.PlayerState.ENDED) {
playNextVideo();
}
}
document.onkeydown = function(e) {
e = e || window.event;
if (e.keyCode === 39) {
playNextVideo();
}
};
setTimeout(function() {document.body.removeChild(document.getElementById('intro'))},20000);
</script>
</body>
</html>