First pass at sync working. Need to ignore for special cases
This commit is contained in:
@ -2,29 +2,26 @@ using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Aurora.Proto.Party;
|
||||
using Aurora.Proto.General;
|
||||
using Aurora.Proto.Playback;
|
||||
using Aurora.Proto.Sync;
|
||||
|
||||
namespace Aurora.Models.Media
|
||||
{
|
||||
public class RemoteAudio : BaseMedia
|
||||
{
|
||||
private RemotePartyService.RemotePartyServiceClient _client;
|
||||
private RemotePlaybackService.RemotePlaybackServiceClient _remotePlaybackClient;
|
||||
private RemoteSyncService.RemoteSyncServiceClient _remoteSyncClient;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
#region Constructor
|
||||
public RemoteAudio(string id, RemotePartyService.RemotePartyServiceClient client)
|
||||
public RemoteAudio(string id, AudioMetadata metadata,
|
||||
RemotePlaybackService.RemotePlaybackServiceClient playbackClient,
|
||||
RemoteSyncService.RemoteSyncServiceClient syncClient)
|
||||
{
|
||||
this.Id = id;
|
||||
this._client = client;
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
public RemoteAudio(string id, AudioMetadata metadata, RemotePartyService.RemotePartyServiceClient client)
|
||||
{
|
||||
this.Id = id;
|
||||
this._client = client;
|
||||
this._remotePlaybackClient = playbackClient;
|
||||
this._remoteSyncClient = syncClient;
|
||||
this.Metadata = metadata;
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
@ -41,6 +38,14 @@ namespace Aurora.Models.Media
|
||||
get { return MediaTypeEnum.Audio; }
|
||||
}
|
||||
|
||||
public RemoteSyncService.RemoteSyncServiceClient RemoteSyncClient
|
||||
{
|
||||
get
|
||||
{
|
||||
return _remoteSyncClient;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
/// <summary>
|
||||
@ -49,8 +54,7 @@ namespace Aurora.Models.Media
|
||||
public override async Task Load()
|
||||
{
|
||||
this.DataStream = new MemoryStream();
|
||||
|
||||
using (var call = _client.GetSongStream(new SongRequest() { Id = this.Id }))
|
||||
using (var call = _remotePlaybackClient.GetSongStream(new SongRequest() { Id = this.Id }))
|
||||
{
|
||||
while (await call.ResponseStream.MoveNext(_cancellationTokenSource.Token))
|
||||
{
|
||||
@ -58,7 +62,6 @@ namespace Aurora.Models.Media
|
||||
byte[] buffer = chunk.Content.ToByteArray();
|
||||
|
||||
await this.DataStream.WriteAsync(buffer, 0, buffer.Length);
|
||||
Console.WriteLine(string.Format("Wrote byte chunk of size {0} to output stream", buffer.Length));
|
||||
}
|
||||
Console.WriteLine("Done receiving stream");
|
||||
|
||||
|
Reference in New Issue
Block a user