-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-example.html
More file actions
81 lines (62 loc) · 2.31 KB
/
app-example.html
File metadata and controls
81 lines (62 loc) · 2.31 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body style="background:#000" style="margin:0; padding:0">
<div id="youtube-container" style="height:80vh"></div>
<div>
<button id="play-button">Play/Pause Video</button>
<button id="seek-ahead-button">Seek Ahead</button>
<button id="seek-back-button">Seek Back</button>
</div>
</body>
</html>
<script src="./js/youtube.proxy.class.js"></script>
<script>
let youtubePlayer = new YouTubeProxy('youtube-container',{
videoId : 'aqz-KE-bpKQ', // Example video ID
proxyURL : 'https://your.server.com/proxy.html', // Should be hosted on server
/* Origin settings */
appOrigin: 'ionic://localhost', // Your app domain where your app is hosted
webOrigin: 'https://your.server.com', // Your web domain where the proxy is hosted
/* YouTube Player API options */
playerVars : {
playsinline : 1,
controls : 0,
autoplay : 1,
color : 'white',
modestbranding: 1
},
/* YouTube Player API events */
events: {
onReady: function(event) {
console.log('YouTube Player is ready');
},
onStateChange: function(event) {
console.log('YouTube Player state changed:', event.data);
playing = event.data === 1;
},
onError: function(event) {
console.error('YouTube Player error:', event.data);
}
}
});
let playing = false;
document.getElementById('play-button').addEventListener('click', () => {
if (playing) {
youtubePlayer.pauseVideo();
playing = false;
} else {
youtubePlayer.playVideo();
playing = true;
}
});
document.getElementById('seek-ahead-button').addEventListener('click', () => {
youtubePlayer.seekTo(youtubePlayer.getCurrentTime() + 10);
});
document.getElementById('seek-back-button').addEventListener('click', () => {
youtubePlayer.seekTo(youtubePlayer.getCurrentTime() - 10);
});
</script>