Skip to content

Commit

Permalink
fix m3u preview
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Jul 13, 2024
1 parent 91e28f3 commit c277bbb
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions packages/docs/public/oplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,6 @@
}
})

if (playlist.length) {
player.applyPlugin(
new OPlugin.Playlist({
initialIndex: p,
autoHide: false,
sources: playlist,
m3uList: m3u
? {
sourceFormat(info) {
try {
const chunk = info.title.substring(3).split('" ')
const titleWith = /group-title="(.+",.+)/.exec(info.title)
const posterWith = /tvg-logo="(.+)"/.exec(info.title)
return {
src: info.uri,
format: 'm3u8',
title: titleWith ? titleWith[1] : /group-title="(.+)"/.exec(info.title)[1],
poster: posterWith && posterWith[1]
}
} catch (error) {
return { src: info.uri, title: info.title, format: 'm3u8' }
}
}
}
: false
})
)
}

if (danmaku || playlist.some((it) => it.danmaku)) {
deps.push([
danmakuScriptCdn,
Expand All @@ -181,6 +152,35 @@
try {
deps.map(([_, fn]) => fn && fn())
} catch (error) {}

if (playlist.length) {
player.applyPlugin(
new OPlugin.Playlist({
initialIndex: p,
autoHide: false,
sources: playlist,
m3uList: m3u
? {
sourceFormat(info) {
try {
const chunk = info.title.substring(3).split('" ')
const titleWith = /group-title="(.+",.+)/.exec(info.title)
const posterWith = /tvg-logo="(.+)"/.exec(info.title)
return {
src: info.uri,
format: 'm3u8',
title: titleWith ? titleWith[1] : /group-title="(.+)"/.exec(info.title)[1],
poster: posterWith && posterWith[1]
}
} catch (error) {
return { src: info.uri, title: info.title, format: 'm3u8' }
}
}
}
: false
})
)
}
})

player.on('ratechange', () => {
Expand Down

0 comments on commit c277bbb

Please sign in to comment.