diff --git a/examples/standalone/main.ts b/examples/standalone/main.ts index 362cb819..68642b6d 100644 --- a/examples/standalone/main.ts +++ b/examples/standalone/main.ts @@ -252,27 +252,6 @@ function stopLoad() { let src: string = player.context.playlist.options.sources[initialIndex].src -const actions = () => - html`

- (src = e.target.value)} style="width:100%;" .value=${live(src)} /> - - - - -

` - -render(actions(), document.getElementById('actions')!) - -player.on((e: PlayerEvent) => { - render(actions(), document.getElementById('actions')!) - - if ('timeupdate' == e.type || 'notice' === e.type || 'progress' === e.type) { - return - } - - console.log(e) -}) - render( html`
diff --git a/packages/hls/README.md b/packages/hls/README.md index 9cf4115b..534239a6 100644 --- a/packages/hls/README.md +++ b/packages/hls/README.md @@ -37,11 +37,12 @@ npm i @oplayer/hls hls.js OHls({ forceHLS: true, // use hls.js not native defaultQuality(levels) { - let index = -1 // -1 => 'auto' - for (const { height, id } of levels) { - if (height <= 1080) index = id + let id = -1 // -1 => 'auto' + for (let i = 0; i < levels.length; i++) { + if (levels[i].height <= 1080) id = i } - return i + + return id }, defaultAudio(tracks) { for (const { lang, id } of object) { diff --git a/packages/hls/package.json b/packages/hls/package.json index 94555c5a..4aa99593 100644 --- a/packages/hls/package.json +++ b/packages/hls/package.json @@ -1,6 +1,6 @@ { "name": "@oplayer/hls", - "version": "1.2.27-beta.1", + "version": "1.2.27-beta.2", "description": "Hls plugin for oplayer", "type": "module", "main": "./dist/index.es.js", diff --git a/packages/hls/src/index.ts b/packages/hls/src/index.ts index 7397efb1..3b70e8c6 100644 --- a/packages/hls/src/index.ts +++ b/packages/hls/src/index.ts @@ -212,7 +212,7 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti name: 'Quality', settings() { return instance.levels.reduce( - (pre, level) => { + (pre, level, id) => { let name = (level.name || level.height).toString() if (isFinite(+name)) name += 'p' if (options.withBitrate) { @@ -222,7 +222,7 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti name += ` (${number}${useMb ? 'm' : 'k'}bps)` } - pre.push({ name, default: defaultLevel == level.id, value: level.id }) + pre.push({ name, default: defaultLevel == id, value: id }) return pre }, [{ name: player.locales.get('Auto'), default: instance.autoLevelEnabled, value: -1 }]