-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathtypes.d.ts
127 lines (98 loc) · 2.77 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
interface OptionsBase {
/**
* The video element to attach listeners to
*/
video?: HTMLVideoElement,
/**
* The canvas to render the subtitles to.
* If none is given it will create a new canvas and insert it as a sibling of the video element (only if the video element exists)
*/
canvas?: HTMLCanvasElement,
/**
* The URL of the worker
*
* @default `subtitles-octopus-worker.js`
*/
workerUrl?: string,
/**
* The URL of the legacy worker
*
* @default `subtitles-octopus-worker-legacy.js`
*/
legacyWorkerUrl?: string,
/**
* An array of links to the fonts used in the subtitle
*/
fonts?: string[]
/**
* Object with all available fonts - Key is font name in lower case, value is link
*
* @example `{"arial": "/font1.ttf"}`
*/
availableFonts?: Record<string, string>
/**
* The amount of time the subtitles should be offset from the video
*
* @default 0
*/
timeOffset?: number
/**
* Whether performance info is printed in the console
*
* @default false
*/
debug?: boolean
/**
* Function that's called when SubtitlesOctopus is ready
*/
onReady?: () => void
/**
* Function called in case of critical error meaning the subtitles wouldn't be shown
* and you should use an alternative method (for instance it occurs if browser doesn't support web workers)
*/
onError?: () => void
/**
* Enable Fast Render Mode (Lossy)
*
* This is experimental feature
*
* @default false
* @see https://github.com/libass/JavascriptSubtitlesOctopus#fast-render-mode-lossy-experimental
*/
lossyRender?: boolean
}
interface OptionsWithSubUrl extends OptionsBase {
subUrl: string
}
interface OptionsWithSubContent extends OptionsBase {
subContent: string
}
export type Options = OptionsWithSubUrl | OptionsWithSubContent
declare class SubtitlesOctopus {
constructor(options: Options)
/**
* Render subtitles at specified time
* @param time
*/
setCurrentTime(time: number): void
/**
* Works the same as the {@link subUrl} option. It will set the subtitle to display by its URL.
* @param url
*/
setTrackByUrl(url: string): void
/**
* Works the same as the {@link subContent} option. It will set the subtitle to display by its content.
* @param content
*/
setTrack(content: string): void
/**
* This simply removes the subtitles.
* You can use {@link setTrackByUrl} or {@link setTrack} methods to set a new subtitle file to be displayed.
*/
freeTrack(): void
/**
* Destroy instance
*/
dispose(): void
}
export default SubtitlesOctopus