-
Notifications
You must be signed in to change notification settings - Fork 9
/
pseudo.html
51 lines (47 loc) · 1.87 KB
/
pseudo.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
<!DOCTYPE html>
<head>
</head>
<body>
<video id="video" controls></video>
<script type="module">
import Hls, { BufferController } from 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.11/hls.light.mjs';
class OreOreBufferController extends BufferController {
constructor(hls, fragmentTracker) {
super(hls, fragmentTracker);
this.onOreOreBufferFlushHandler = this.onOreOreBufferFlush.bind(this);
this.dontflush = false;
}
onBufferReset() {
if (this.dontflush) {
this.dontflush = false;
return;
}
super.onBufferReset();
}
onMediaAttaching(event, data) {
super.onMediaAttaching(event, data);
this.media.addEventListener('seeking', this.onOreOreBufferFlushHandler);
}
onMediaDetaching() {
this.media.removeEventListener('seeking', this.onOreOreBufferFlushHandler);
super.onMediaDetaching();
}
onOreOreBufferFlush() {
this.hls.trigger(Hls.Events.BUFFER_FLUSHING, {
startOffset: 0,
endOffset: Number.POSITIVE_INFINITY,
type: null,
});
this.dontflush = true;
this.hls.trigger(Hls.Events.MANIFEST_LOADING, {
url: `http://localhost:8080/playlist.m3u8?t=${this.media.currentTime}&_=${crypto.randomUUID()}`
});
}
}
const video = document.getElementById('video');
const hls = new Hls({ bufferController: OreOreBufferController, debug: false});
const url = 'http://localhost:8080/playlist.m3u8?t=0';
hls.loadSource(url);
hls.attachMedia(video);
</script>
</body>