From d31f0b30481f6180e7907aee27413e5d208539aa Mon Sep 17 00:00:00 2001 From: RblSb Date: Sun, 7 Jun 2020 18:45:22 +0300 Subject: Playlists "at next" order --- src/client/Main.hx | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/client/Main.hx') diff --git a/src/client/Main.hx b/src/client/Main.hx index 1cf4b04..c8750ca 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -14,6 +14,7 @@ import js.Browser; import js.Browser.document; import js.Browser.window; import Client.ClientData; +import Types.VideoDataRequest; import Types.VideoData; import Types.Config; import Types.WsEvent; @@ -213,16 +214,19 @@ class Main { final links = url.split("|"); handleUrlMasks(links); // if videos added as next, we need to load them in reverse order - if (!atEnd) { - // except first item when list empty - var first:Null = null; - if (player.isListEmpty()) first = links.shift(); - links.reverse(); - if (player.isListEmpty()) links.unshift(first); - } + if (!atEnd) sortItemsForQueueNext(links); addVideoArray(links, atEnd, isTemp); } + public function sortItemsForQueueNext(items:Array):Void { + if (items.length == 0) return; + // except first item when list empty + var first:Null = null; + if (player.isListEmpty()) first = items.shift(); + items.reverse(); + if (player.isListEmpty()) items.unshift(first); + } + function addVideoArray(links:Array, atEnd:Bool, isTemp:Bool):Void { if (links.length == 0) return; final link = links.shift(); @@ -238,7 +242,11 @@ class Main { } if (!url.startsWith("http")) url = '$protocol//$url'; - player.getVideoData(url, (data:VideoData) -> { + final obj:VideoDataRequest = { + url: url, + atEnd: atEnd + }; + player.getVideoData(obj, (data:VideoData) -> { if (data.duration == 0) { serverMessage(4, Lang.get("addVideoError")); return; @@ -271,7 +279,11 @@ class Main { mediaTitle.value = ""; final checkbox:InputElement = cast ge("#customembed").querySelector(".add-temp"); final isTemp = checkbox.checked; - player.getIframeData(iframe, (data:VideoData) -> { + final obj:VideoDataRequest = { + url: iframe, + atEnd: atEnd + }; + player.getIframeData(obj, (data:VideoData) -> { if (data.duration == 0) { serverMessage(4, Lang.get("addVideoError")); return; -- cgit v1.2.3