mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-16 09:36:16 -08:00
31 lines
907 B
TypeScript
31 lines
907 B
TypeScript
import type Artplayer from 'artplayer'
|
|
import type { Input, Options } from './types'
|
|
|
|
export function normalizeOptions(input: Input | undefined, validate: typeof Artplayer.validator): Options {
|
|
// The legacy declaration accepts strings, but this unchanged validator proves
|
|
// numeric runtime durations before the result crosses the declaration boundary.
|
|
return validate({
|
|
html: '',
|
|
video: '',
|
|
url: '',
|
|
playDuration: 5,
|
|
totalDuration: 10,
|
|
muted: false,
|
|
i18n: {
|
|
close: '关闭广告',
|
|
countdown: '%s秒',
|
|
detail: '查看详情',
|
|
canBeClosed: '%s秒后可关闭广告',
|
|
},
|
|
...input,
|
|
}, {
|
|
html: '?string',
|
|
video: '?string',
|
|
url: '?string',
|
|
playDuration: 'number',
|
|
totalDuration: 'number',
|
|
muted: '?boolean',
|
|
i18n: { close: 'string', countdown: 'string', detail: 'string', canBeClosed: 'string' },
|
|
}) as Options
|
|
}
|