Skip to content

Commit

Permalink
fix #135
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Aug 31, 2024
1 parent d49f3de commit aa08dea
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
21 changes: 0 additions & 21 deletions examples/standalone/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,27 +252,6 @@ function stopLoad() {

let src: string = player.context.playlist.options.sources[initialIndex].src

const actions = () =>
html`<p style="display:flex;">
<input type="text" @input=${(e: any) => (src = e.target.value)} style="width:100%;" .value=${live(src)} />
<button @click=${() => player.changeSource({ src })}>Load</button>
<button @click=${stopLoad}>StopLoad</button>
</p> `

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`
<div>
Expand Down
9 changes: 5 additions & 4 deletions packages/hls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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.27-beta.1",
"version": "1.2.27-beta.2",
"description": "Hls plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/hls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 }]
Expand Down

0 comments on commit aa08dea

Please sign in to comment.