mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 13:21:20 -08:00
refactor(multiple-subtitles): [PKG-MULTI-SUB-04] expose compatible runtime type entry
This commit is contained in:
1 parent
7f226ff822
commit
d44e81ce22
34 files changed
+3346
-60
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
import type { RuntimeFactory } from '../types/artplayer-plugin-multiple-subtitles'
|
||||
import type { Option, Result, Track } from './types'
|
||||
import installCaptionView from './caption'
|
||||
import createLifetime from './lifetime'
|
||||
@@ -6,7 +7,7 @@ import { parseTracks, serializeTracks } from './merge'
|
||||
import createRenderer from './render'
|
||||
import loadVtt from './request'
|
||||
|
||||
export default function artplayerPluginMultipleSubtitles({ subtitles = [] }: Option) {
|
||||
function artplayerPluginMultipleSubtitles({ subtitles = [] }: Option) {
|
||||
return async (art: Artplayer): Promise<Result> => {
|
||||
const { unescape, getExt, srtToVtt, assToVtt } = (art.constructor as typeof Artplayer).utils
|
||||
const lifetime = createLifetime(art)
|
||||
@@ -44,3 +45,5 @@ export default function artplayerPluginMultipleSubtitles({ subtitles = [] }: Opt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Object.assign(artplayerPluginMultipleSubtitles, { default: artplayerPluginMultipleSubtitles }) as RuntimeFactory
|
||||
@@ -4,15 +4,7 @@ import type legacyFactory from '../types/artplayer-plugin-multiple-subtitles'
|
||||
import type { ParseResult } from './parser'
|
||||
|
||||
export type LegacyOption = Parameters<typeof legacyFactory>[0]
|
||||
export type TrackOption = LegacyOption['subtitles'][number]
|
||||
export interface Option {
|
||||
subtitles?: TrackOption[]
|
||||
}
|
||||
export interface Result {
|
||||
name: 'multipleSubtitles'
|
||||
tracks: (names?: string[]) => void
|
||||
reset: () => void
|
||||
}
|
||||
export type { RuntimeOption as Option, Result, TrackOption } from '../types/artplayer-plugin-multiple-subtitles'
|
||||
export interface Track extends ParseResult {
|
||||
url: string | undefined
|
||||
name: string | undefined
|
||||
|
||||
Reference in new issue
Block a user