aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Main.hx6
-rw-r--r--src/client/Player.hx10
2 files changed, 15 insertions, 1 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx
index deeb2ec..0844636 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -25,6 +25,7 @@ class Main {
static inline var SETTINGS_VERSION = 2;
public final settings:ClientSettings;
public var isSyncActive = true;
+ public var forceSyncNextTick = false;
final clients:Array<Client> = [];
var pageTitle = document.title;
final host:String;
@@ -371,6 +372,8 @@ class Main {
case VideoLoaded:
player.setTime(0);
player.play();
+ // try to sync leader after with GetTime events
+ if (isLeader() && !player.isVideoLoaded()) forceSyncNextTick = true;
case RemoveVideo:
player.removeItem(data.removeVideo.url);
@@ -401,13 +404,14 @@ class Main {
final synchThreshold = settings.synchThreshold;
final newTime = data.getTime.time;
final time = player.getTime();
- if (isLeader()) {
+ if (isLeader() && !forceSyncNextTick) {
// if video is loading on leader
// move other clients back in time
if (Math.abs(time - newTime) < synchThreshold) return;
player.setTime(time, false);
return;
}
+ if (player.isVideoLoaded()) forceSyncNextTick = false;
if (player.getDuration() < player.getTime()) return;
if (!data.getTime.paused) player.play();
else player.pause();
diff --git a/src/client/Player.hx b/src/client/Player.hx
index ad10814..cdbccfd 100644
--- a/src/client/Player.hx
+++ b/src/client/Player.hx
@@ -280,8 +280,14 @@ class Player {
public function refresh():Void {
if (items.length == 0) return;
+ final time = getTime();
removeVideo();
setVideo(itemPos);
+ // restore server time for leader with next GetTime
+ if (main.isLeader()) {
+ setTime(time);
+ main.forceSyncNextTick = true;
+ }
}
function duration(time:Float):String {
@@ -323,6 +329,10 @@ class Player {
return items[itemPos].duration;
}
+ public function isVideoLoaded():Bool {
+ return player.isVideoLoaded();
+ }
+
public function play():Void {
if (!main.isSyncActive) return;
if (player == null) return;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage