forked from anime-kun32/AniTeams-amvstrm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathte.html
More file actions
335 lines (300 loc) · 10.9 KB
/
te.html
File metadata and controls
335 lines (300 loc) · 10.9 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Artplayer with Thumbnails</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.container {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #000;
overflow: hidden;
}
.artplayer-app {
width: 100vw;
height: 100vh;
background: #000;
box-sizing: border-box;
}
@media (max-width: 768px) {
.artplayer-app {
width: 100vw;
height: 100vh;
}
}
@media (max-width: 1024px) {
.artplayer-app {
width: 100vw;
height: 100vh;
}
}
</style>
</head>
<body>
<div class="artplayer-app"></div>
<script src="https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/artplayer-plugin-chromecast/dist/artplayer-plugin-chromecast.js"></script>
<script src="https://cdn.jsdelivr.net/npm/artplayer-plugin-thumbnail@1.0.3/dist/artplayer-plugin-vtt-thumbnail.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const baseApiUrl = 'https://api-p1xr.vercel.app/api/v2/stream';
let art = null;
let thumbnail = null;
const getQueryParam = (param) => {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
};
const id = getQueryParam('id');
if (!id) {
console.error('No ID provided in URL');
return;
}
const fetchVideoData = () => {
const apiUrl = `${baseApiUrl}/${id}`;
return fetch(apiUrl)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.catch(error => {
console.error('Error fetching API data:', error);
});
};
const saveCurrentTime = (videoId, time) => {
localStorage.setItem(`lastSeen-${videoId}`, time);
};
const getLastSeenTime = (videoId) => {
return localStorage.getItem(`lastSeen-${videoId}`);
};
const initializePlayer = (data) => {
if (!data || !data.stream || !data.stream.multi || !data.stream.multi.main || !data.stream.multi.backup) {
console.error('Invalid data received from API:', data);
return;
}
// Set video source to the proxy URL
const videoSource = `https://gogoanime-and-hianime-proxy.vercel.app/hls-proxy?url=${encodeURIComponent(data.stream.multi.main.url)}`;
const backupSource = `https://gogoanime-and-hianime-proxy.vercel.app/hls-proxy?url=${encodeURIComponent(data.stream.multi.backup.url)}`;
const thumbnailTrack = data.stream.tracks && data.stream.tracks.kind === 'thumbnails' ? {
label: "Thumbnails",
file: data.stream.tracks.file
} : null;
document.title = data.info.title;
const lastSeenTime = getLastSeenTime(id);
if (art) {
art.destroy();
}
const customLoading = `
<div style="display:flex; justify-content:center; align-items:center; height:100%;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<circle cx="50" cy="50" r="45" stroke-width="10" stroke="#f00" fill="none" stroke-dasharray="283" stroke-dashoffset="75">
<animateTransform attributeName="transform" type="rotate" from="0 50 50" to="360 50 50" dur="1s" repeatCount="indefinite"/>
</circle>
</svg>
</div>
`;
art = new Artplayer({
container: '.artplayer-app',
url: videoSource,
type: 'm3u8',
screenshot: true,
setting: true,
autoplay: true,
fullscreen: true,
fullscreenWeb: true,
airplay: true,
playsInline: true,
live:true,
plugins: [
artplayerPluginChromecast({}),
],
settings: [
{
html: 'Speed',
selector: [
{ html: '1.0x', playbackRate: 1.0, default: true },
{ html: '1.5x', playbackRate: 1.5 },
{ html: '2.0x', playbackRate: 2.0 },
],
onSelect: function (item) {
art.playbackRate = item.playbackRate;
return item.html;
},
},
{
html: 'Source',
selector: [
{ html: 'Main', url: videoSource, default: true },
{ html: 'Backup', url: backupSource },
],
onSelect: function (item) {
art.switchUrl(item.url);
return item.html;
},
},
{
html: 'Jump Forward',
selector: [
{ html: '10s', time: 10 },
{ html: '30s', time: 30 },
{ html: '60s', time: 60 },
],
onSelect: function (item) {
art.currentTime += item.time;
return item.html;
},
},
{
html: 'Jump Backward',
selector: [
{ html: '10s', time: -10 },
{ html: '30s', time: -30 },
{ html: '60s', time: -60 },
],
onSelect: function (item) {
art.currentTime += item.time;
return item.html;
},
},
],
customType: {
m3u8: function (video, url) {
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
video.addEventListener('loadedmetadata', () => {
video.play();
});
} else {
art.notice.show('Does not support playback of m3u8');
}
}
},
moreVideoAttr: {
'webkit-playsinline': true,
'playsinline': true,
},
lock: true,
customL: customLoading, // Using the custom loading SVG
});
art.on('video:timeupdate', () => {
saveCurrentTime(id, art.currentTime);
});
if (lastSeenTime) {
art.notice.show(
`Resume from last seen position?`,
[
{
html: 'Yes',
onClick: () => {
art.currentTime = parseFloat(lastSeenTime);
art.notice.hide();
},
},
{
html: 'No',
onClick: () => {
art.notice.hide();
},
},
],
5000,
);
}
const backButton = document.createElement('div');
backButton.innerHTML = '<';
backButton.style.position = 'absolute';
backButton.style.top = '10px';
backButton.style.left = '10px';
backButton.style.fontSize = '24px';
backButton.style.color = 'white';
backButton.style.cursor = 'pointer';
backButton.style.zIndex = '9999';
backButton.addEventListener('click', () => {
window.history.back();
});
const playerContainer = document.querySelector('.artplayer-app');
playerContainer.appendChild(backButton);
art.on('fullscreen', (state) => {
if (state) {
screen.orientation.lock('landscape').catch(() => {
console.error('Screen orientation lock failed');
});
} else {
screen.orientation.unlock().catch(() => {
console.error('Screen orientation unlock failed');
});
}
});
// Initialize thumbnail tool
if (thumbnail) {
thumbnail.destroy();
}
thumbnail = new ArtplayerToolThumbnail({
fileInput: document.querySelector('.artplayer-app'),
number: 60,
width: 160,
column: 10,
begin: 0,
end: NaN,
});
thumbnail.on('file', (file) => {
console.log('Read video successfully: ' + file.name);
});
thumbnail.on('video', (video) => {
console.log('Video size: ' + video.videoWidth + ' x ' + video.videoHeight);
console.log('Video duration: ' + video.duration + 's');
thumbnail.start();
});
thumbnail.on('canvas', (canvas) => {
console.log('Build canvas successfully');
console.log('Canvas size: ' + canvas.width + ' x ' + canvas.height);
console.log('Preview density: ' + thumbnail.density + ' p/s');
});
thumbnail.on('update', (url, percentage) => {
console.log('Processing: ' + Math.floor(percentage.toFixed(2) * 100) + '%');
});
thumbnail.on('download', (name) => {
console.log('Start download preview: ' + name);
});
thumbnail.on('done', () => {
console.log(' preview image complete');
thumbnail.download();
new Artplayer({
container: '.artplayer-app',
url: videoSource,
autoSize: true,
poster: thumbnail.thumbnailUrl,
thumbnails: {
url: thumbnail.thumbnailUrl,
number: thumbnail.option.number,
column: thumbnail.option.column,
},
});
console.log('Build player complete');
});
};
fetchVideoData().then(initializePlayer);
});
</script>
</body>
</html>