mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 10:41:20 -08:00
fix(dash): [PKG-DASH-05] align nullable SDK metadata and validate real types
This commit is contained in:
1 parent
c4b5f5f454
commit
2ad00730ee
25 files changed
+1255
-25
No files matched your search
@@ -34,6 +34,7 @@ const dashOption: artplayerPluginDashControl.Option = {
|
||||
const oldQuality: NonNullable<Parameters<typeof artplayerPluginDashControl>[0]['quality']> = { getName: (value: object) => String(value) }
|
||||
const typedFactory: (art: Artplayer) => artplayerPluginDashControl.Result = artplayerPluginDashControl(dashOption)
|
||||
const defaultFactory = artplayerPluginDashControl()
|
||||
const unknownTrack: artplayerPluginDashControl.AudioTrack = { id: null, index: null, lang: null }
|
||||
`, 'typescript', api.Uri.parse('file:///dash-consumer.ts'))
|
||||
const invalid = api.editor.createModel('artplayerPluginDashControl({ quality: { getName: level => level.height } })', 'typescript', api.Uri.parse('file:///dash-invalid.ts'))
|
||||
try {
|
||||
|
||||
@@ -6,6 +6,23 @@ import { bothMenus, dashHost, dashImplementations } from './helpers/dash-control
|
||||
const candidates = (await dashImplementations()).filter(item => item.name.startsWith('source') || item.name.startsWith('artifact'))
|
||||
const { factory } = candidates[0]
|
||||
for (const { sdk, name, factory } of candidates) {
|
||||
test(`DASH ${sdk} (${name}): nullable SDK audio metadata retains labels and original track identity`, () => {
|
||||
const host = dashHost(sdk)
|
||||
const track = { id: null, index: null, lang: null }
|
||||
host.state.tracks = [track]
|
||||
host.state.currentTrack = track
|
||||
factory(bothMenus())(host.art).update()
|
||||
const menu = host.controls.get('dash-audio')
|
||||
assert.equal(menu.html, null)
|
||||
assert.equal(menu.selector[0].default, true)
|
||||
assert.equal(menu.selector[0].value, track)
|
||||
host.calls.length = 0
|
||||
assert.equal(menu.onSelect(menu.selector[0]), null)
|
||||
assert.equal(host.calls[0][0], 'setCurrentTrack')
|
||||
assert.equal(host.calls[0][1], track)
|
||||
assert.equal(host.state.currentTrack, track)
|
||||
})
|
||||
|
||||
test(`DASH ${sdk} (${name}): supports the original SDK method generation and stable selection keys`, () => {
|
||||
const host = dashHost(sdk)
|
||||
factory(bothMenus())(host.art).update()
|
||||
|
||||
@@ -18,6 +18,7 @@ const objectConfig: Config = { getName: (item: object) => String(item) }
|
||||
dashControl({ quality: objectConfig, audio: objectConfig })
|
||||
const level: QualityLevel = { height: 720, id: 0 }
|
||||
const track: AudioTrack = { id: 'en', lang: 'en' }
|
||||
const unknownTrack: AudioTrack = { id: null, index: null, lang: null }
|
||||
|
||||
interface CustomLevel { height: number, bandwidth: number }
|
||||
interface CustomTrack { id: number, lang: string, roles: string[] }
|
||||
@@ -40,4 +41,4 @@ legacy({ quality: { control: 'yes' } })
|
||||
dashControl(null)
|
||||
// @ts-expect-error Default SDK fields cannot silently become any.
|
||||
dashControl({ quality: { getName: level => level.unknownProperty } })
|
||||
void [done, level, track, promise, invalidName]
|
||||
void [done, level, track, unknownTrack, promise, invalidName]
|
||||
Reference in new issue
Block a user