-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.js
50 lines (47 loc) · 1.21 KB
/
all.js
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
// Local variables
// YT Player initializer
player = new YT.Player('player', {
// width: w,
// height: h,
videoId: "5lN4EAIrJNo",
'origin': location.origin,
playerVars: {
'autoplay': 1,
'origin': location.origin,
'rel' : 0
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
// Helper for processing YTPlayer triggers
function onPlayerReady()
{
$('#videoReadyButton').prop('disabled', false);
}
function onPlayerStateChange(ev)
{
if (ev.data == YT.PlayerState.ENDED || ev.data == YT.PlayerState.PAUSED) {
if (currTimeInterval) {
clearInterval(currTimeInterval);
currTimeInterval = null;
}
inPreview = false;
}
if (ev.data == YT.PlayerState.PLAYING) {
currTimeInterval = window.setInterval(function() {
$('#currentTime').val(secToTime(player.getCurrentTime()));
if (inPreview && player.getCurrentTime() >= timeToSec($('#endTime').val()) - 0.05) {
inPreview = false;
player.pauseVideo();
}
}, 100);
$('#backButton').prop('disabled', true);
$('#forwardButton').prop('disabled', true);
} else {
$('#backButton').prop('disabled', false);
$('#forwardButton').prop('disabled', false);
}
updateControls();
}