First pass at syncing worked with some bug fixes
This commit is contained in:
@ -15,7 +15,9 @@ namespace Aurora.Models.Media
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
#region Constructor
|
||||
public RemoteAudio(string id, AudioMetadata metadata,
|
||||
public RemoteAudio(string id,
|
||||
bool fromHost,
|
||||
AudioMetadata metadata,
|
||||
RemotePlaybackService.RemotePlaybackServiceClient playbackClient,
|
||||
RemoteSyncService.RemoteSyncServiceClient syncClient)
|
||||
{
|
||||
@ -23,6 +25,7 @@ namespace Aurora.Models.Media
|
||||
this._remotePlaybackClient = playbackClient;
|
||||
this._remoteSyncClient = syncClient;
|
||||
this.Metadata = metadata;
|
||||
this.FromHost = fromHost;
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
}
|
||||
@ -46,6 +49,7 @@ namespace Aurora.Models.Media
|
||||
}
|
||||
}
|
||||
|
||||
public bool FromHost { get; private set; }
|
||||
#endregion Properties
|
||||
|
||||
/// <summary>
|
||||
@ -56,15 +60,21 @@ namespace Aurora.Models.Media
|
||||
this.DataStream = new MemoryStream();
|
||||
using (var call = _remotePlaybackClient.GetSongStream(new SongRequest() { Id = this.Id }))
|
||||
{
|
||||
while (await call.ResponseStream.MoveNext(_cancellationTokenSource.Token))
|
||||
try
|
||||
{
|
||||
Chunk chunk = call.ResponseStream.Current;
|
||||
byte[] buffer = chunk.Content.ToByteArray();
|
||||
while (await call.ResponseStream.MoveNext(_cancellationTokenSource.Token))
|
||||
{
|
||||
Chunk chunk = call.ResponseStream.Current;
|
||||
byte[] buffer = chunk.Content.ToByteArray();
|
||||
|
||||
await this.DataStream.WriteAsync(buffer, 0, buffer.Length);
|
||||
await this.DataStream.WriteAsync(buffer, 0, buffer.Length);
|
||||
}
|
||||
Console.WriteLine("Done receiving stream");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Exception caught while loading remote audio:" + ex.Message);
|
||||
}
|
||||
Console.WriteLine("Done receiving stream");
|
||||
|
||||
}
|
||||
await base.Load();
|
||||
}
|
||||
|
Reference in New Issue
Block a user