-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
30 lines (29 loc) · 952 Bytes
/
example.html
File metadata and controls
30 lines (29 loc) · 952 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
<video id="videoPlayer" controls>
<source src="/music/index.m3u8" type="application/x-mpegURL">
<source src="/music/index.mpd" type="application/dash+xml">
<source src="/music.mp4" type="video/mp4">
</video>
<script>
var video = document.querySelector("#videoPlayer");
var dashUrl = "/music/index.mpd";
var hlsUrl = "/music/index.m3u8";
if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(hlsUrl);
hls.attachMedia(video);
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = hlsUrl;
} else if (dashjs.supportsMediaSource()) {
var player = dashjs.MediaPlayer().create();
player.initialize(video, dashUrl, true);
}
</script>
</body>
</html>