diff options
| author | RblSb <msrblsb@gmail.com> | 2021-02-14 06:46:05 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2021-02-14 06:46:05 +0300 |
| commit | 600156045aa6f93c79fd57ee4e76d588b3f734e6 (patch) | |
| tree | 85f1910e202091a2c446e21a4f938214c66b311c /src/client/JsApi.hx | |
| parent | 5b4d9c6257f7563ef685ab383037906355fbf054 (diff) | |
Subtitles url input
Can be enabled by plugins
Diffstat (limited to 'src/client/JsApi.hx')
| -rw-r--r-- | src/client/JsApi.hx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/client/JsApi.hx b/src/client/JsApi.hx index b0938f8..b97c0f0 100644 --- a/src/client/JsApi.hx +++ b/src/client/JsApi.hx @@ -6,6 +6,7 @@ import Types.VideoItem; import js.Browser.document; import js.Browser.window; import js.Syntax; +using StringTools; private typedef VideoChangeFunc = (item:VideoItem)->Void; private typedef OnceEventFunc = (event:WsEvent)->Void; @@ -14,6 +15,7 @@ class JsApi { static var main:Main; static var player:Player; + static final subtitleFormats = []; static final videoChange:Array<VideoChangeFunc> = []; static final videoRemove:Array<VideoChangeFunc> = []; static final onceListeners:Array<{type:WsEventType, func:OnceEventFunc}> = []; @@ -101,6 +103,19 @@ class JsApi { } @:expose + static function addSubtitleSupport(format:String):Void { + format = format.trim().toLowerCase(); + if (subtitleFormats.contains(format)) return; + subtitleFormats.push(format); + } + + @:expose + public static function hasSubtitleSupport(?format:String):Bool { + if (format == null) return subtitleFormats.length > 0; + return subtitleFormats.contains(format); + } + + @:expose public static function once(type:WsEventType, func:OnceEventFunc):Void { onceListeners.push({type: type, func: func}); } |
