aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-06-07 18:45:22 +0300
committerRblSb <msrblsb@gmail.com>2020-06-07 18:45:22 +0300
commitd31f0b30481f6180e7907aee27413e5d208539aa (patch)
treead1281ef9f5100bd05108dc42b8f5107f585444a /src/client/Main.hx
parentf2567959538d7a7b26aa405353c2dbea4e6cc945 (diff)
Playlists "at next" order
Diffstat (limited to 'src/client/Main.hx')
-rw-r--r--src/client/Main.hx30
1 files changed, 21 insertions, 9 deletions
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<String> = 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<T>(items:Array<T>):Void {
+ if (items.length == 0) return;
+ // except first item when list empty
+ var first:Null<T> = null;
+ if (player.isListEmpty()) first = items.shift();
+ items.reverse();
+ if (player.isListEmpty()) items.unshift(first);
+ }
+
function addVideoArray(links:Array<String>, 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;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage