First pass at syncing worked with some bug fixes
This commit is contained in:
@ -19,18 +19,22 @@ namespace Aurora.RemoteImpl
|
||||
Grpc.Core.IServerStreamWriter<Sync> responseStream,
|
||||
Grpc.Core.ServerCallContext context)
|
||||
{
|
||||
bool songIsPlaying = true;
|
||||
PlaybackStateChangedEventHandler playbackStateChanged = (sender, e) =>
|
||||
bool continueSync = true;
|
||||
string currentId = PlayerService.Instance.CurrentMedia.Id;
|
||||
MediaChangedEventHandler mediaChanged = (sender, e) =>
|
||||
{
|
||||
songIsPlaying = false;
|
||||
if (e.NewId != currentId)
|
||||
{
|
||||
continueSync = false;
|
||||
}
|
||||
};
|
||||
|
||||
PlayerService.Instance.PlaybackStateChanged += playbackStateChanged;
|
||||
PlayerService.Instance.MediaChanged += mediaChanged;
|
||||
|
||||
while (songIsPlaying)
|
||||
while (continueSync)
|
||||
{
|
||||
DateTime time = Utils.TimeUtils.GetNetworkTime();
|
||||
float position = PlayerService.Instance.CurrentMediaTime;
|
||||
float position = PlayerService.Instance.CurrentMediaPosition;
|
||||
float length = PlayerService.Instance.CurrentMediaLength;
|
||||
|
||||
float trackTime = length * position;
|
||||
@ -41,7 +45,8 @@ namespace Aurora.RemoteImpl
|
||||
ServerTime = time.Ticks
|
||||
};
|
||||
await responseStream.WriteAsync(sync);
|
||||
await Task.Delay(10000);
|
||||
Console.WriteLine("Sent Sync");
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user