Spiele Filme in allen Playern über die gespeicherte Qualitätsleiter.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8e77defaca
commit
1fb48783bf
14 files changed
+202
-18
No files matched your search
+30
-2
@@ -1,12 +1,18 @@
|
||||
import Hls from 'hls.js';
|
||||
|
||||
document.querySelectorAll('video[data-hls]').forEach((video) => {
|
||||
function attachPlayback(video) {
|
||||
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
const source = video.dataset.hls;
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
video.dataset.playbackReady = '1';
|
||||
|
||||
if (Hls.isSupported()) {
|
||||
const playback = new Hls();
|
||||
playback.loadSource(source);
|
||||
@@ -18,7 +24,29 @@ document.querySelectorAll('video[data-hls]').forEach((video) => {
|
||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = source;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function scanPlayback(root) {
|
||||
if (root instanceof HTMLVideoElement) {
|
||||
attachPlayback(root);
|
||||
}
|
||||
|
||||
if (root instanceof Element) {
|
||||
root.querySelectorAll('video[data-hls]').forEach(attachPlayback);
|
||||
}
|
||||
}
|
||||
|
||||
scanPlayback(document);
|
||||
|
||||
new MutationObserver((records) => {
|
||||
records.forEach((record) => {
|
||||
record.addedNodes.forEach((node) => {
|
||||
if (node instanceof Element) {
|
||||
scanPlayback(node);
|
||||
}
|
||||
});
|
||||
});
|
||||
}).observe(document.documentElement, { childList: true, subtree: true });
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const fullscreen = event.target.closest('[data-fullscreen]');
|
||||
|
||||
Reference in new issue
Block a user