diff options
| author | RblSb <msrblsb@gmail.com> | 2020-04-01 18:08:09 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-04-01 18:08:09 +0300 |
| commit | 6fa4100b5237c64ca1e6e4f1c2ed30654f4feb79 (patch) | |
| tree | 15aab54b2c14517c161eb260650b945795c35821 /src | |
| parent | 6effda5b228804f2b9d622c1db94684974b05828 (diff) | |
Delay before next video
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/Main.hx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx index 90dfe2f..f056ac6 100644 --- a/src/server/Main.hx +++ b/src/server/Main.hx @@ -23,6 +23,8 @@ using Lambda; class Main { + static inline var VIDEO_START_MAX_DELAY = 3000; + static inline var VIDEO_SKIP_DELAY = 1000; final rootDir = '$__dirname/..'; final verbose:Bool; final statePath:String; @@ -392,18 +394,24 @@ class Main { final isCurrent = videoList[itemPos].url == url; itemPos = videoList.removeItem(index, itemPos); if (isCurrent && videoList.length > 0) { - restartWaitTimer(); + Timer.delay(() -> { + broadcast(data); + restartWaitTimer(); + }, VIDEO_SKIP_DELAY); + } else { + broadcast(data); } - broadcast(data); case SkipVideo: if (!checkPermission(client, RemoveVideoPerm)) return; if (videoList.length == 0) return; final item = videoList[itemPos]; if (item.url != data.skipVideo.url) return; - itemPos = videoList.skipItem(itemPos); - if (videoList.length > 0) restartWaitTimer(); - broadcast(data); + Timer.delay(() -> { + itemPos = videoList.skipItem(itemPos); + if (videoList.length > 0) restartWaitTimer(); + broadcast(data); + }, VIDEO_SKIP_DELAY); case Pause: if (videoList.length == 0) return; @@ -421,7 +429,7 @@ class Main { case GetTime: if (videoList.length == 0) return; - if (videoTimer.getTime() > videoList[itemPos].duration) { + if (videoTimer.getTime() > videoList[itemPos].duration - 0.01) { videoTimer.stop(); onMessage(client, { type: SkipVideo, skipVideo: { @@ -607,7 +615,7 @@ class Main { function restartWaitTimer():Void { videoTimer.stop(); if (waitVideoStart != null) waitVideoStart.stop(); - waitVideoStart = Timer.delay(startVideoPlayback, 3000); + waitVideoStart = Timer.delay(startVideoPlayback, VIDEO_START_MAX_DELAY); } function prepareVideoPlayback():Void { |
