diff options
| -rw-r--r-- | res/client.js | 10 | ||||
| -rw-r--r-- | src/client/players/Raw.hx | 11 |
2 files changed, 6 insertions, 15 deletions
diff --git a/res/client.js b/res/client.js index 0f339f6..94af960 100644 --- a/res/client.js +++ b/res/client.js @@ -2416,6 +2416,7 @@ var client_players_Raw = function(main,player) { this.isHlsLoaded = false; this.playAllowed = true; this.matchName = new EReg("^(.+)\\.(.+)",""); + this.titleInput = window.document.querySelector("#mediatitle"); this.playerEl = window.document.querySelector("#ytapiplayer"); this.main = main; this.player = player; @@ -2429,7 +2430,7 @@ client_players_Raw.prototype = { var _gthis = this; var url = data.url; var decodedUrl = decodeURIComponent(url.split("+").join(" ")); - var optTitle = this.cutOptionalTitle(); + var optTitle = StringTools.trim(this.titleInput.value); var title = HxOverrides.substr(decodedUrl,decodedUrl.lastIndexOf("/") + 1,null); var isNameMatched = this.matchName.match(title); if(optTitle != "") { @@ -2451,6 +2452,7 @@ client_players_Raw.prototype = { }); return; } + this.titleInput.value = ""; var video = window.document.createElement("video"); video.src = url; video.onerror = function(e) { @@ -2470,12 +2472,6 @@ client_players_Raw.prototype = { this.initHlsSource(video,url); } } - ,cutOptionalTitle: function() { - var titleInput = window.document.querySelector("#mediatitle"); - var optTitle = StringTools.trim(titleInput.value); - titleInput.value = ""; - return optTitle; - } ,loadHlsPlugin: function(callback) { var _gthis = this; client_JsApi.addScriptToHead("https://cdn.jsdelivr.net/npm/hls.js@latest",function() { diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx index fdb5e73..2b1530d 100644 --- a/src/client/players/Raw.hx +++ b/src/client/players/Raw.hx @@ -17,6 +17,7 @@ class Raw implements IPlayer { final main:Main; final player:Player; final playerEl:Element = ge("#ytapiplayer"); + final titleInput:InputElement = cast ge("#mediatitle"); final matchName = ~/^(.+)\.(.+)/; var controlsHider:Timer; var playAllowed = true; @@ -36,7 +37,7 @@ class Raw implements IPlayer { final url = data.url; final decodedUrl = url.urlDecode(); - final optTitle = cutOptionalTitle(); + final optTitle = titleInput.value.trim(); var title = decodedUrl.substr(decodedUrl.lastIndexOf("/") + 1); final isNameMatched = matchName.match(title); if (optTitle != "") title = optTitle; @@ -51,6 +52,7 @@ class Raw implements IPlayer { return; } + titleInput.value = ""; final video = document.createVideoElement(); video.src = url; video.onerror = e -> { @@ -68,13 +70,6 @@ class Raw implements IPlayer { if (isHls) initHlsSource(video, url); } - function cutOptionalTitle():String { - final titleInput:InputElement = cast ge("#mediatitle"); - final optTitle = titleInput.value.trim(); - titleInput.value = ""; - return optTitle; - } - function loadHlsPlugin(callback:()->Void):Void { final url = "https://cdn.jsdelivr.net/npm/hls.js@latest"; JsApi.addScriptToHead(url, () -> { |
