-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplayer.html
90 lines (87 loc) · 3.37 KB
/
player.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sonic X Player</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/artplayer.css">
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #000;
}
#player {
width: 80%;
height: 80%;
}
</style>
</head>
<body>
<div id="player"></div>
<script src="https://unpkg.com/[email protected]/dist/artplayer.js"></script>
<script src="https://unpkg.com/[email protected]"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const player = new Artplayer({
container: '#player',
url: 'https://www117.vipanicdn.net/streamhls/2980ce020218d0edf93036466119e67c/ep.1.1709546392.m3u8',
plugins: [
artplayerPluginChromecast({
receiverAppId: 'CC1AD845', // Replace with your Chromecast Receiver App ID if you have one
}),
],
subtitle: {
url: 'https://cache.anicdn.stream/images/84dc876a331cec3d614d902d7dbd1c3c/1.vtt',
type: 'vtt',
style: {
color: '#fff',
fontSize: '20px',
},
},
moreVideoAttr: {
crossOrigin: 'anonymous',
},
customType: {
m3u8: function (video, url) {
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
}
},
},
controls: [
{
name: 'screenshot',
html: '📸',
tooltip: 'Screenshot',
click: function () {
player.screenshot();
},
},
],
fullscreen: true,
fullscreenWeb: true,
});
player.on('screenshot', (img) => {
const a = document.createElement('a');
a.href = img;
a.download = 'screenshot.png';
a.click();
});
player.on('error', function (error) {
console.error('Error:', error);
player.switchUrl('https://www117.anicdnstream.info/videos/hls/auZuAl3GrpXpb6Fu1EPGYg/1722380772/130897/2980ce020218d0edf93036466119e67c/ep.1.1709546392.m3u8');
});
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artplayer/5.1.6/artplayer.js" integrity="sha512-yt3XDU6xYOc5xMiWa3h8tYMJMcZzLJo7YvTBOl3F9n568gppuXRiMh2rRz2yOtReGcGBFubsQuMeTFymUZKj/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</body>
</html>