-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutubeplayer.html
61 lines (54 loc) · 1.53 KB
/
youtubeplayer.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>YouTube Player</title>
<style>
/* Ensure the body and html take the full height of the viewport */
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden; /* Prevent scrollbars */
}
/* Style the player to fill the entire page */
#player {
width: 100vw; /* Use viewport width */
height: 100vh; /* Use viewport height */
background: #000; /* Optional: Background color */
}
</style>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
videoId: 'rQwME8G1Cgs', // Default video ID
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
console.log("Player is ready");
}
function playVideo() {
console.log("playVideo called");
player.playVideo();
}
function pauseVideo() {
console.log("pauseVideo called");
player.pauseVideo();
}
function seekTo(seconds) {
player.seekTo(seconds, true);
}
function loadNewVideo(videoId) {
player.loadVideoById(videoId);
}
</script>
</head>
<body>
<div id="player"></div>
</body>
</html>