Skip to content

Commit

Permalink
fix(ui): slider pointer events
Browse files Browse the repository at this point in the history
fix(hls): sort quality
  • Loading branch information
shiyiya authored Sep 12, 2024
1 parent 15ee5f5 commit 1759725
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
26 changes: 13 additions & 13 deletions packages/danmaku/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default (options = {} as Options): PlayerPlugin => ({
//@ts-ignore
if (player.isNativeUI) return

const { speed = 144, opacity, engine = 'dom', displaySender, area = 0.8, fontSize } = options
const { speed = 144, opacity, engine = 'dom', displaySender, area = 1, fontSize } = options

const $danmaku = $.render($.create('div'), player.$root)
$danmaku.style.cssText = `font-weight: normal;position: absolute;left: 0;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;text-shadow: rgb(0 0 0) 1px 0px 1px, rgb(0 0 0) 0px 1px 1px, rgb(0 0 0) 0px -1px 1px, rgb(0 0 0) -1px 0px 1px;color:#fff;`
Expand All @@ -37,7 +37,7 @@ export default (options = {} as Options): PlayerPlugin => ({
media: player.$video,
engine: engine,
comments: [],
speed: isMobile ? speed / 1.5 : speed,
speed: isMobile ? speed / 1.5 : speed
}) as any

danmaku.setFontSize = function setFontSize(value: number) {
Expand Down Expand Up @@ -139,7 +139,7 @@ export default (options = {} as Options): PlayerPlugin => ({
} else {
danmaku.hide()
}
},
}
},
{
name: player.locales.get('Heatmap'),
Expand All @@ -149,7 +149,7 @@ export default (options = {} as Options): PlayerPlugin => ({
onChange: (value: Boolean) => {
if (value) danmaku.heatmap?.enable()
else danmaku.heatmap?.disable()
},
}
},
{
type: 'selector',
Expand All @@ -158,12 +158,12 @@ export default (options = {} as Options): PlayerPlugin => ({
children: [0.5, 0.75, 1, 1.25].map((it) => ({
name: `${it * 100}%`,
value: it,
default: it == 1,
default: it == 1
})),
onChange: ({ value }: any) => {
options.fontSize = value
danmaku.setFontSize(value)
},
}
},
{
type: 'selector',
Expand All @@ -172,11 +172,11 @@ export default (options = {} as Options): PlayerPlugin => ({
children: [0.3, 0.5, 0.8, 1].map((it) => ({
name: `${it * 100}%`,
value: it,
default: it == (options?.opacity || 1),
default: it == (options?.opacity || 1)
})),
onChange: ({ value }: any) => {
$danmaku.style.opacity = value
},
}
},
{
type: 'selector',
Expand All @@ -185,15 +185,15 @@ export default (options = {} as Options): PlayerPlugin => ({
children: [25, 50, 80, 100].map((it) => ({
name: `${it}%`,
value: it,
default: it == area * 100,
default: it == area * 100
})),
onChange: ({ value }: any) => {
options.opacity = value
$danmaku.style.height = `${value}%`
danmaku.resize()
},
},
],
}
}
]
})
}

Expand All @@ -202,5 +202,5 @@ export default (options = {} as Options): PlayerPlugin => ({
if (displaySender && !isMobile) registerInput(player, danmaku, options)

return danmaku
},
}
})
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.3",
"version": "1.2.27-beta.4",
"description": "Hls plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
2 changes: 1 addition & 1 deletion 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
.toSorted((a, b) => b.bitrate - a.bitrate)
.sort((a, b) => b.bitrate - a.bitrate)
.reduce(
(pre, level, id) => {
let name = (level.name || level.height).toString()
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.3.3-beta.9",
"version": "1.3.3-beta.10",
"description": "ui plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Setting.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const settingItemCls = $.css({
display: 'flex',
overflow: 'hidden',

'& > *': { 'pointer-events': 'none' },
'&:not([aria-label=slider]) > *': { 'pointer-events': 'none' },

'&:hover': {
'background-color': 'rgba(255, 255, 255, 0.1)'
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/components/Setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ function createRow({
let $item: HTMLElement = $.create(`div.${settingItemCls}`, {
'data-key': key,
role: type == 'option' ? 'menuitemradio' : 'menuitem',
'aria-haspopup': type == 'selector'
'aria-haspopup': hasChildren ? 'menu' : false,
'aria-label': type || 'menuitem'
})
const res = {
$row: $item,
Expand Down

0 comments on commit 1759725

Please sign in to comment.