diff options
| author | RblSb <msrblsb@gmail.com> | 2021-07-04 03:59:50 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2021-07-05 17:04:25 +0300 |
| commit | ede45cea8706eb8540e466df9861c2af8ebf9c44 (patch) | |
| tree | 74a20a6f082173378f918b48b08542881f31749a /src/client/players | |
| parent | 265b3e1fb56bb0e5f797b3b35227a616b108a0c3 (diff) | |
Reformat
Diffstat (limited to 'src/client/players')
| -rw-r--r-- | src/client/players/Iframe.hx | 15 | ||||
| -rw-r--r-- | src/client/players/Raw.hx | 19 | ||||
| -rw-r--r-- | src/client/players/Youtube.hx | 21 |
3 files changed, 25 insertions, 30 deletions
diff --git a/src/client/players/Iframe.hx b/src/client/players/Iframe.hx index ae37c94..e07f814 100644 --- a/src/client/players/Iframe.hx +++ b/src/client/players/Iframe.hx @@ -1,14 +1,13 @@ package client.players; -import js.html.Element; -import js.Browser.document; -import client.Main.ge; -import Types.VideoDataRequest; import Types.VideoData; +import Types.VideoDataRequest; import Types.VideoItem; +import client.Main.ge; +import js.Browser.document; +import js.html.Element; class Iframe implements IPlayer { - final main:Main; final player:Player; final playerEl:Element = ge("#ytapiplayer"); @@ -23,7 +22,7 @@ class Iframe implements IPlayer { return true; } - public function getVideoData(data:VideoDataRequest, callback:(data:VideoData)->Void):Void { + public function getVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void):Void { final iframe = document.createDivElement(); iframe.innerHTML = data.url; if (isValidIframe(iframe)) { @@ -35,8 +34,7 @@ class Iframe implements IPlayer { function isValidIframe(iframe:Element):Bool { if (iframe.children.length != 1) return false; - return (iframe.firstChild.nodeName == "IFRAME" - || iframe.firstChild.nodeName == "OBJECT"); + return (iframe.firstChild.nodeName == "IFRAME" || iframe.firstChild.nodeName == "OBJECT"); } public function loadVideo(item:VideoItem):Void { @@ -79,5 +77,4 @@ class Iframe implements IPlayer { } public function setPlaybackRate(rate:Float):Void {} - } diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx index cafe147..ea51e97 100644 --- a/src/client/players/Raw.hx +++ b/src/client/players/Raw.hx @@ -1,19 +1,19 @@ package client.players; -import js.hlsjs.Hls; +import Types.VideoData; +import Types.VideoDataRequest; +import Types.VideoItem; +import client.Main.ge; import haxe.Timer; +import js.Browser.document; +import js.hlsjs.Hls; import js.html.Element; import js.html.InputElement; import js.html.VideoElement; -import js.Browser.document; -import client.Main.ge; -import Types.VideoDataRequest; -import Types.VideoData; -import Types.VideoItem; + using StringTools; class Raw implements IPlayer { - final main:Main; final player:Player; final playerEl:Element = ge("#ytapiplayer"); @@ -34,7 +34,7 @@ class Raw implements IPlayer { return true; } - public function getVideoData(data:VideoDataRequest, callback:(data:VideoData)->Void):Void { + public function getVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void):Void { final url = data.url; final decodedUrl = url.urlDecode(); @@ -77,7 +77,7 @@ class Raw implements IPlayer { if (isHls) initHlsSource(video, url); } - function loadHlsPlugin(callback:()->Void):Void { + function loadHlsPlugin(callback:() -> Void):Void { final url = "https://cdn.jsdelivr.net/npm/hls.js@latest"; JsApi.addScriptToHead(url, () -> { isHlsLoaded = true; @@ -177,5 +177,4 @@ class Raw implements IPlayer { public function setPlaybackRate(rate:Float):Void { video.playbackRate = rate; } - } diff --git a/src/client/players/Youtube.hx b/src/client/players/Youtube.hx index e63a095..d4db8ed 100644 --- a/src/client/players/Youtube.hx +++ b/src/client/players/Youtube.hx @@ -1,19 +1,19 @@ package client.players; -import haxe.Json; +import Types.VideoData; +import Types.VideoDataRequest; +import Types.VideoItem; +import client.Main.ge; import haxe.Http; -import js.html.Element; +import haxe.Json; import js.Browser.document; -import client.Main.ge; +import js.html.Element; import js.youtube.Youtube as YtInit; import js.youtube.YoutubePlayer; -import Types.VideoDataRequest; -import Types.VideoData; -import Types.VideoItem; + using StringTools; class Youtube implements IPlayer { - final matchId = ~/youtube\.com.*v=([A-z0-9_-]+)/; final matchShort = ~/youtu\.be\/([A-z0-9_-]+)/; final matchEmbed = ~/youtube\.com\/embed\/([A-z0-9_-]+)/; @@ -73,7 +73,7 @@ class Youtube implements IPlayer { return total; } - public function getVideoData(data:VideoDataRequest, callback:(data:VideoData)->Void):Void { + public function getVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void):Void { final url = data.url; if (apiKey == null) apiKey = main.getYoutubeApiKey(); final id = extractVideoId(url); @@ -122,7 +122,7 @@ class Youtube implements IPlayer { http.request(); } - function getPlaylistVideoData(data:VideoDataRequest, callback:(data:VideoData)->Void):Void { + function getPlaylistVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void):Void { final url = data.url; final id = extractPlaylistId(url); var maxResults = main.getYoutubePlaylistLimit(); @@ -174,7 +174,7 @@ class Youtube implements IPlayer { main.serverMessage(4, 'Error $code: $msg', false); } - function getRemoteDataFallback(url:String, callback:(data:VideoData)->Void):Void { + function getRemoteDataFallback(url:String, callback:(data:VideoData) -> Void):Void { if (!YtInit.isLoadedAPI) { YtInit.init(() -> getRemoteDataFallback(url, callback)); return; @@ -292,5 +292,4 @@ class Youtube implements IPlayer { public function setPlaybackRate(rate:Float):Void { youtube.setPlaybackRate(rate); } - } |
