From 243bdc947a26ac92ad2084af47cfc7501f837d40 Mon Sep 17 00:00:00 2001 From: shiyiya Date: Sat, 13 Jul 2024 22:23:13 +0800 Subject: [PATCH] - --- packages/docs/public/oplayer.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/docs/public/oplayer.js b/packages/docs/public/oplayer.js index 350a9934..d22cf861 100644 --- a/packages/docs/public/oplayer.js +++ b/packages/docs/public/oplayer.js @@ -8,7 +8,8 @@ deps = [], m3u = false, p = undefined, - title = '❤OPlayer' + title = '❤OPlayer', + txt = '' var _query = decodeURIComponent(query || '') if (_query.startsWith('http')) { @@ -26,6 +27,7 @@ m3u = safeDecodeURIComponent(search.get('m3u')) p = search.has('p') ? search.get('p') : undefined p == '' ? (p = undefined) : (p = +p) + txt = safeDecodeURIComponent(search.get('txt')) subtitle = search.get('subtitle') ? { @@ -62,6 +64,19 @@ deps.push(['https://cdn.jsdelivr.net/npm/m3u8-parser@7.1.0/dist/m3u8-parser.min.js']) } + if (txt) { + fetch(txt) + .then((r) => r.text()) + .then((text) => { + console.log(text.split('\n')) + playlist = text.split('\n').map((line) => { + const [title, src] = line.split(',') + return { title, src: src } + }) + }) + .then(applyPlaylist) + } + var player = OPlayer.make('#oplayer', { source: { src, poster, title: title }, playbackRate: localStorage.getItem('@oplayer/UserPreferences/speed') || 1, @@ -153,6 +168,10 @@ deps.map(([_, fn]) => fn && fn()) } catch (error) {} + applyPlaylist() + }) + + function applyPlaylist() { if (playlist.length) { player.applyPlugin( new OPlugin.Playlist({ @@ -181,7 +200,7 @@ }) ) } - }) + } player.on('ratechange', () => { if (!player.isSourceChanging)