Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Feb 8, 2024
1 parent d91a638 commit 043c8e1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 29 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

- https://oplayer.vercel.app
- https://ohplayer.netlify.app
- Quick Start
- https://ohplayer.netlify.app/ohls.html?src=https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8
- https://oplayer.vercel.app/ohls.html?src=https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8

## Who use OPlayer?

Expand Down
33 changes: 15 additions & 18 deletions examples/standalone/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,17 @@ const player = Player.make<Ctx>('#player', {
m3uList: {
sourceFormat(info) {
const chunk = info.title.substring(3).split(' ')
const titleWith = chunk.find(it => it.includes('title')).split('=')[1]
const posterWith = chunk.find(it => it.includes('logo'))?.split('=')[1]
const titleWith = chunk.find((it) => it.includes('title')).split('=')[1]
const posterWith = chunk.find((it) => it.includes('logo'))?.split('=')[1]
return {
src: info.uri,
format: 'm3u8',
title: titleWith.substring(1, titleWith.length),
poster: posterWith?.substring(1, posterWith.length),
poster: posterWith?.substring(1, posterWith.length)
}
},
}
},
sources: [
{
src: 'https://raw.githubusercontent.com/fanmingming/live/main/tv/m3u/global.m3u'
},
{
title: '君の名は - MP4',
poster: POSTER,
Expand Down Expand Up @@ -245,18 +242,18 @@ const actions = () => html`<p style="display:flex;">
<button
@click=${() => {
src =
VIDEO_LIST[
currentDataSrcId + 1 >= VIDEO_LIST.length ? (currentDataSrcId = 0) : (currentDataSrcId += 1)
]!
src =
VIDEO_LIST[
currentDataSrcId + 1 >= VIDEO_LIST.length ? (currentDataSrcId = 0) : (currentDataSrcId += 1)
]!
player.changeSource(
new Promise<Source>((r) => {
stopLoad()
r({ src })
})
)
}}
player.changeSource(
new Promise<Source>((r) => {
stopLoad()
r({ src })
})
)
}}
>
Queue
</button>
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/public/ohls.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
} else {
var search = new URLSearchParams(document.location.search)
src = safeDecodeURIComponent(search.get('src'))
playlist = JSON.parse(safeDecodeURIComponent(search.get('playlist')) || [])
playlist = JSON.parse(safeDecodeURIComponent(search.get('playlist')) || '[]')
poster = safeDecodeURIComponent(search.get('poster'))
title = safeDecodeURIComponent(search.get('title'))
danmaku = safeDecodeURIComponent(search.get('danmaku'))
Expand Down
2 changes: 1 addition & 1 deletion packages/hls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/hls",
"version": "1.2.24.beta.0",
"version": "1.2.24.beta.1",
"description": "Hls plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
13 changes: 5 additions & 8 deletions packages/hls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ class HlsPlugin implements PlayerPlugin {

instance?: Hls

options: RequiredPartial<HlsPluginOptions, 'active' | 'inactive' | 'errorHandler'> = {
options: RequiredPartial<HlsPluginOptions, 'active' | 'inactive'> = {
config: {},
forceHLS: false,
textControl: true,
audioControl: true,
qualityControl: true,
withBitrate: false,
qualitySwitch: 'immediate',
matcher: defaultMatcher
matcher: defaultMatcher,
errorHandler: defaultErrorHandler
}

constructor(options?: HlsPluginOptions) {
Expand Down Expand Up @@ -136,11 +137,7 @@ class HlsPlugin implements PlayerPlugin {
instance.loadSource(source.src)
instance.attachMedia($video)
instance.on(HlsPlugin.library.Events.ERROR, function (_, data) {
if (errorHandler) {
errorHandler(player, data, defaultErrorHandler)
} else {
defaultErrorHandler(player, data)
}
errorHandler(player, data, defaultErrorHandler)
})

if (player.context.ui?.setting) {
Expand All @@ -158,7 +155,7 @@ class HlsPlugin implements PlayerPlugin {
if (this.instance) {
// prettier-ignore
const { player, instance, options: { inactive } } = this
if (inactive) inactive(instance!, HlsPlugin.library)
if (inactive) inactive(instance, HlsPlugin.library)
if (player.context.ui?.setting) removeSetting(player)
instance.destroy()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/ui",
"version": "1.2.34",
"version": "1.2.35.beta-0",
"description": "ui plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down

0 comments on commit 043c8e1

Please sign in to comment.