This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
119 lines (97 loc) · 2.94 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<title><youtube-video></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"
/>
<style>
body {
text-align: center;
}
media-controller,
youtube-video {
display: block;
width: 100%;
aspect-ratio: 16 / 9;
background: #000;
}
</style>
<script type="module" src="./youtube-video-element.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/media-chrome/+esm"></script>
</head>
<body>
<h1><youtube-video></h1>
<br />
<youtube-video id="yt1" muted controls src="https://www.youtube.com/watch?v=rubNgGj3pYo"></youtube-video>
<br>
<button id="loadbtn">Load new clip</button>
<br>
<h2>With <a href="https://github.com/muxinc/media-chrome" target="_blank">Media Chrome</a></h2>
<media-controller>
<youtube-video
id="yt2"
src="https://www.youtube.com/watch?v=H3KSKS3TTbc"
slot="media"
autopause
></youtube-video>
<media-control-bar>
<media-play-button></media-play-button>
<media-seek-backward-button seek-offset="15"></media-seek-backward-button>
<media-seek-forward-button seek-offset="15"></media-seek-forward-button>
<media-mute-button></media-mute-button>
<media-volume-range></media-volume-range>
<media-time-range></media-time-range>
<media-time-display show-duration remaining></media-time-display>
<media-playback-rate-button></media-playback-rate-button>
<media-fullscreen-button></media-fullscreen-button>
</media-control-bar>
</media-controller>
<br>
<br>
<script>
const video = document.querySelector('#yt2');
window.addEventListener('load', function() {
document.querySelector('#yt1').currentTime = 23;
});
loadbtn.onclick = () => {
video.src = 'https://www.youtube.com/watch?v=H3KSKS3TTbc';
}
video.addEventListener('loadstart', (e) => {
console.log(e.type);
});
video.addEventListener('play', (e) => {
console.log(e.type);
});
video.addEventListener('waiting', (e) => {
console.log(e.type);
});
video.addEventListener('playing', (e) => {
console.log(e.type);
});
video.addEventListener('pause', (e) => {
console.log(e.type);
});
video.addEventListener('seeking', (e) => {
console.log(e.type);
});
video.addEventListener('seeked', (e) => {
console.log(e.type);
});
video.addEventListener('ended', (e) => {
console.log(e.type);
});
video.addEventListener('durationchange', (e) => {
console.log(e.type, video.duration);
});
video.addEventListener('volumechange', (e) => {
console.log(e.type, video.volume);
});
video.addEventListener('resize', (e) => {
console.log(e.type, video.videoWidth, video.videoHeight);
});
</script>
</body>
</html>