forked from bento-n-box/jQuery.YoutubeBackground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
257 lines (238 loc) · 7.38 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
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Jquery Youtube Fullscreen Background Video</title>
<meta name="keywords" content="background, video, jquery, plugin, javascript, css, 360, youtube">
<meta name="description" content="Create fullscreen youtube background videos with this jquery plugin.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Twitter Boostrap for Demo -->
<link rel="stylesheet" href="http:////maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- styles for video player -->
<link rel="stylesheet" href="src/style.css">
</head>
<body>
<div id="background-video" class="background-video">
<img src="images/placeholder.jpg" alt="" class="placeholder-image">
</div>
<div class="padding container">
<h1>Jquery Youtube Background Video</h1>
<p class="lead">A simple wrapper for the YouTube API to create background videos</p>
<div id="anotherVideo"></div>
<h2><a href="/360.html"> Now with 360 video support!</a></h2>
</div>
<div class="container options">
<div class="row">
<div class="span12">
<h1>Customizing</h1>
<h2>1. Options</h2>
<p>All of the options below are available to customize your Youtube Background Player </p>
<table class="table hp-table table-bordered table-striped">
<thead>
<tr>
<th>Variable</th>
<th>Default</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="text-emp">ratio</span></td>
<td>ratio: 16 / 9</td>
<td>int</td>
<td>Sets video ratio dimensions</td>
</tr>
<tr>
<td><span class="text-emp">videoId</span></td>
<td>LSmgKRx5pBo</td>
<td>String</td>
<td>Video Id: Specifies which Youtube Video</td>
</tr>
<tr>
<td><span class="text-emp">mute</span></td>
<td>true</td>
<td>boolean</td>
<td>Mutes Youtube Video</td>
</tr>
<tr>
<td><span class="text-emp">width</span></td>
<td>$(window).width()</td>
<td>int</td>
<td>Expands Video to width of container</td>
</tr>
<tr>
<td><span class="text-emp">pauseOnScroll</span></td>
<td>false</td>
<td>boolean</td>
<td>Pauses Video During Scroll to help performance</td>
</tr>
<tr>
<td><span class="text-emp">repeat</span></td>
<td>true</td>
<td>boolean</td>
<td>Loops Video</td>
</tr>
<tr>
<td><span class="text-emp">fitToBackground</span></td>
<td>true</td>
<td>boolean</td>
<td>Fits to background vs fitting to the container specified with width</td>
</tr>
<tr>
<td><span class="text-emp">start</span></td>
<td>0</td>
<td>int</td>
<td>Second in which video should begin playing at</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="container options">
<div class="row">
<div class="span12">
<h1> How to Instantiate</h1>
<h3>Instantiate plugin</h3>
<pre>
$('#video').YTPlayer({
fitToBackground: true,
videoId: 'LSmgKRx5pBo'
});
</pre>
<h3> Make sure to add some CSS</h3>
<pre>
#video{
position: relative;
background: transparent;
}
.ytplayer-container{
position: absolute;
top: 0;
z-index: -1;
}
</pre>
</div>
</div>
</div>
<div class="container options">
<div class="row">
<div class="span12">
<h2>2. Callbacks</h2>
<h3>Example:</h3>
<pre>
$('#background-video').YTPlayer({
videoId: 'LSmgKRx5pBo',
callback: function() {
console.log("playerFinshed");
}
});
</pre>
<table class="table hp-table table-bordered ">
<thead>
<tr>
<th>Variable</th>
<th>Default</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="text-emp">callback</span></td>
<td>false</td>
<td>function</td>
<td>Once Youtube Player is Ready.</td>
</tr>
</tbody>
</table>
<h2>3. Youtube Api</h2>
<p>The beauty of this player, is you can rely on the Youtube API</p>
<p>To grab the youtube player:</p>
<h3>Example:</h3>
<pre>
var player = $('#background-video').data('ytPlayer').player;
player.pauseVideo();
player.playVideo();
player.addEventListener('onStateChange', function(data){
console.log("Player State Change", data);
});
</pre>
<h3>Leverage Youtubes API's Options</h3>
<pre>
$('#module-video').YTPlayer({
fitToBackground: false,
videoId: 'jKCyFB5LmPo',
pauseOnScroll: false,
playerVars: {
modestbranding: 0,
autoplay: 1,
controls: 1,
showinfo: 0,
wmode: 'transparent',
branding: 0,
rel: 0,
autohide: 0,
origin: window.location.origin
}
});
</pre>
<p>For full documentation view Youtube's Api: <a href="https://developers.google.com/youtube/js_api_reference">https://developers.google.com/youtube/js_api_reference</a></p>
</div>
</div>
</div>
<div class="container options">
<h2>Use plugin for regular videos as well!</h2>
</div>
<div class="container options">
<div id="module-video" class="module-video"></div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- ADD Jquery Video Background -->
<script src="src/jquery.youtubebackground.js"></script>
<script>
jQuery(function($) {
$('#module-video').YTPlayer({
fitToBackground: false,
videoId: 'jKCyFB5LmPo',
pauseOnScroll: false,
playerVars: {
modestbranding: 0,
autoplay: 1,
controls: 1,
showinfo: 0,
branding: 0,
rel: 0,
autohide: 0
}
});
$('#background-video').YTPlayer({
fitToBackground: true,
videoId: 'Fk9EBOOAYiU',
pauseOnScroll: true,
callback: function() {
videoCallbackEvents();
}
});
var videoCallbackEvents = function() {
var player = $('#background-video').data('ytPlayer').player;
player.addEventListener('onStateChange', function(event){
console.log("Player State Change", event);
// OnStateChange Data
if (event.data === 0) {
console.log('video ended');
}
else if (event.data === 2) {
console.log('paused');
}
});
}
});
</script>
</body>
</html>