forked from Ronman73/FrenchPressPlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyt.js
35 lines (34 loc) · 954 Bytes
/
yt.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
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady(click) {
player = new YT.Player('player', {
playerVars: {
listType:'playlist',
list: 'PLrEnWoR732-BHrPp_Pm8_VleD68f9s14-',
index: parseInt(0),
startSeconds:60,
endSeconds:600},
height: '390',
width: '568',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(click) {
event.target.playVideo();
}
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(pauseVideo, 60000);
done = true;
}
}
function pauseVideo() {
player.pauseVideo();
}