Skip to content

Commit aaa8af7

Browse files
committed
Uncomment late join serialize and fix remote stopping
It seems like late join breaks in some worlds or something, so we'll try to enforce a new serialized when people join since it seems like they aren't receiving *any* serialized state sometimes.
1 parent 677d7ed commit aaa8af7

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Assets/USharpVideo/Scripts/USharpVideoPlayer.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ void Start()
196196

197197
// Serialize the default setup state from the master once regardless of if a video has played
198198
QueueSerialize();
199+
200+
LogMessage("USharpVideo v1.0.1 Initialized");
199201
}
200202

201203
public override void OnVideoReady()
@@ -362,7 +364,8 @@ public override void OnVideoError(VideoError videoError)
362364
_currentLoadingTime = RATE_LIMIT_RETRY_TIMEOUT;
363365
return;
364366
}
365-
else if (videoError == VideoError.PlayerError)
367+
368+
if (videoError == VideoError.PlayerError)
366369
{
367370
SetStatusText("Video error, retrying...");
368371
LogError("Video player error when trying to load " + _syncedURL);
@@ -456,7 +459,7 @@ private void Update()
456459
// return !_isMasterOnly || IsPrivlegedUser(requestedOwner);
457460
//}
458461

459-
bool _lastMasterLocked = false;
462+
bool _lastMasterLocked;
460463

461464
public override void OnDeserialization()
462465
{
@@ -475,6 +478,9 @@ public override void OnDeserialization()
475478

476479
if (_isMasterOnly != _lastMasterLocked)
477480
SetLockedInternal(_isMasterOnly);
481+
482+
if (!_ownerPlaying && _videoPlayerManager.IsPlaying())
483+
_videoPlayerManager.Stop();
478484

479485
if (_currentVideoIdx != _syncedVideoIdx)
480486
{
@@ -527,11 +533,11 @@ public override void OnOwnershipTransferred(VRCPlayerApi player)
527533
}
528534

529535
// Supposedly there's some case where late joiners don't receive data, so do a serialization just in case here.
530-
//public override void OnPlayerJoined(VRCPlayerApi player)
531-
//{
532-
// if (!player.isLocal)
533-
// QueueSerialize();
534-
//}
536+
public override void OnPlayerJoined(VRCPlayerApi player)
537+
{
538+
if (!player.isLocal)
539+
QueueSerialize();
540+
}
535541

536542
/// <summary>
537543
/// Stops playback of the video completely and clears data
@@ -552,6 +558,7 @@ public void StopVideo()
552558
_videoTargetStartTime = 0f;
553559
_lastCurrentTime = 0f;
554560

561+
_videoPlayerManager.Stop();
555562
SetUIPaused(false);
556563
ResetVideoLoad();
557564

@@ -594,7 +601,6 @@ void PlayVideoInternal(VRCUrl url, bool stopPlaylist)
594601
if (stopPlaylist)
595602
_nextPlaylistIndex = -1;
596603

597-
_videoPlayerManager.Stop();
598604
StopVideo();
599605

600606
_syncedURL = url;

0 commit comments

Comments
 (0)