Skip to content

Commit e06dd44

Browse files
committed
Fixed stuck at loading screen issue
1 parent 7fe2295 commit e06dd44

File tree

22 files changed

+35
-7
lines changed

22 files changed

+35
-7
lines changed
18 KB
Binary file not shown.

SyncPlayWPF/SyncPlayWPF/Pages/NewSessionPage.xaml.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,18 @@ private void JoinRoom_Clicked(object sender, RoutedEventArgs e) {
4848
Common.Shared.Wrapper.SyncPlayClient.OnDisconnect += SyncPlayClient_OnDisconnect;
4949

5050
Common.Shared.Wrapper.SyncPlayClient.ConnectAsync();
51-
Common.Shared.MasterOverrideTransition.ShowPage(new Pages.ApplicationPages.LoadingScreen());
51+
Common.Shared.MasterOverrideTransition.ShowPage(new Pages.ApplicationPages.LoadingScreen());
52+
5253
}
5354

5455
private void SyncPlayClient_OnDisconnect(SyncPlay.SyncPlayClient sender, SyncPlay.EventArgs.ServerDisconnectedEventArgs e) {
5556
Console.WriteLine($"Failed to connect. Reasons : {e.ReasonForKick}");
5657
Dispatcher.Invoke(() => {
5758
Common.Shared.MasterOverrideTransition.UnloadCurrentPage();
59+
Common.Shared.Wrapper.SyncPlayClient.OnConnect -= SyncPlayClient_OnConnect;
60+
Common.Shared.Wrapper.SyncPlayClient.OnDisconnect -= SyncPlayClient_OnDisconnect;
5861
});
59-
Common.Shared.Wrapper.Player = null;
60-
Common.Shared.Wrapper = null;
62+
Common.Shared.Wrapper.Dispose();
6163
}
6264

6365
private void SyncPlayClient_OnConnect(SyncPlay.SyncPlayClient sender, SyncPlay.EventArgs.ServerConnectedEventArgs e) {

SyncPlayWPF/SyncPlayWPF/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("2021.205.23.0")]
55-
[assembly: AssemblyFileVersion("2021.205.23.0")]
54+
[assembly: AssemblyVersion("2021.205.36.0")]
55+
[assembly: AssemblyFileVersion("2021.205.36.0")]

SyncPlayWPF/SyncPlayWPF/SyncPlay/MediaPlayers/VLCMediaPlayer/Connector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ public void SetPauseState(bool p) {
149149
}
150150

151151
public void ClosePlayer() {
152-
this.PlayerProcess.Kill();
152+
if (this.PlayerProcess != null)
153+
this.PlayerProcess.Kill();
153154
}
154155

155156
public event MediaPlayerInterface.HandleDebugMessages OnDebugMessage;

SyncPlayWPF/SyncPlayWPF/SyncPlay/NetworkClient.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ public bool Connect() {
4444
return true;
4545
}
4646

47+
48+
public void Disconnect() {
49+
this.client.GetStream().Close();
50+
this.client.Close();
51+
}
52+
4753
public void ActivateTLS() {
4854
this.SSL = new SslStream(stream);
4955
this.SSL.AuthenticateAsClient(this.Host);
@@ -81,7 +87,7 @@ private void ProcessIncoming() {
8187
NotifySubscribersOnNewMessage(parts[i].Trim(' '));
8288
}
8389

84-
} catch (IOException e) {
90+
} catch (Exception e) {
8591
Misc.Common.PrintInColor("Stream broken!", ConsoleColor.Red);
8692
Misc.Common.PrintInColor(e.Message, ConsoleColor.Red);
8793
Misc.Common.PrintInColor(e.StackTrace, ConsoleColor.Red);

SyncPlayWPF/SyncPlayWPF/SyncPlay/SyncPlayClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ public void ConnectAsync() {
142142
connectAsyncThread.Start();
143143
}
144144

145+
public void Dispose() {
146+
this.nclient.Disconnect();
147+
}
148+
145149
public bool Connect() {
146150
try {
147151
nclient = new NetworkClient(ServerIP, Port);
@@ -316,6 +320,7 @@ private void NewIncomingMessage(NetworkClient sender, string message) {
316320
if (jobj.ContainsKey("Error")) {
317321
var ErrorMessage = jobj.Value<JObject>("Error")
318322
.Value<String>("message");
323+
Thread.Sleep(3000);
319324
OnDisconnect?.Invoke(this, new EventArgs.ServerDisconnectedEventArgs(true, ErrorMessage));
320325
return;
321326
}

SyncPlayWPF/SyncPlayWPF/SyncPlay/SyncPlayWrapper.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ private void SyncPlayClient_OnConnect(SyncPlayClient sender, EventArgs.ServerCon
2828
this.Player.StartPlayerInstance();
2929
}
3030

31+
32+
3133
private void NewFileLoad(EventArgs.NewFileLoadEventArgs e) {
3234
SyncPlayClient.AddFileToPlayList(e.AbsoluteFilePath);
3335
}
@@ -36,5 +38,17 @@ private void PlayerStateChanged(SyncPlayClient sender, EventArgs.RemoteStateChan
3638
Player.SetPauseState(e.Paused);
3739
Player.SetPosition(e.Position + RemoteSeekOffset);
3840
}
41+
42+
public void Dispose() {
43+
if (Player != null) {
44+
Player.ClosePlayer();
45+
Player = null;
46+
}
47+
48+
if (SyncPlayClient != null) {
49+
SyncPlayClient.Dispose();
50+
SyncPlayClient = null;
51+
}
52+
}
3953
}
4054
}
512 Bytes
Binary file not shown.
4 KB
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)