-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (50 loc) · 1.51 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Player</title>
</head>
<body>
<div id="player"></div>
<script>
// Define an array of sample YouTube video IDs
var videoIds = [
'SG4zcXW8prE',
'd7qdsCmXag4',
'9Im3hIQFC7w',
'FOWxc7BzEvI'
];
// Initialize the YouTube player
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '360',
width: '640',
playerVars: {
'autoplay': 1,
'controls': 1,
'rel': 0,
'showinfo': 1,
'loop': 1,
'playlist': videoIds.join(',')
},
events: {
'onReady': onPlayerReady
}
});
}
// Function to start changing the video every 30 seconds
function onPlayerReady(event) {
setInterval(changeVideo, 40000);
}
// Function to change the video
function changeVideo() {
var randomIndex = Math.floor(Math.random() * videoIds.length);
player.loadVideoById(videoIds[randomIndex]);
}
</script>
<!-- Include the YouTube IFrame API script -->
<script src="https://www.youtube.com/iframe_api"></script>
</body>
</html>