Successfully playing a song in a party with one member
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Aurora.Proto.Party;
|
||||
using Aurora.Proto.General;
|
||||
|
||||
@ -45,7 +46,7 @@ namespace Aurora.Models.Media
|
||||
/// <summary>
|
||||
/// Override load method.
|
||||
/// </summary>
|
||||
public override async void Load()
|
||||
public override async Task Load()
|
||||
{
|
||||
this.DataStream = new MemoryStream();
|
||||
|
||||
@ -56,13 +57,13 @@ namespace Aurora.Models.Media
|
||||
Chunk chunk = call.ResponseStream.Current;
|
||||
byte[] buffer = chunk.Content.ToByteArray();
|
||||
|
||||
await this.DataStream.WriteAsync(buffer, 0, buffer.Length, _cancellationTokenSource.Token);
|
||||
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");
|
||||
|
||||
}
|
||||
base.Load();
|
||||
await base.Load();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -70,13 +71,13 @@ namespace Aurora.Models.Media
|
||||
/// </summary>
|
||||
public override void Unload()
|
||||
{
|
||||
if (!_cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
_cancellationTokenSource.Cancel();
|
||||
// if (!_cancellationTokenSource.IsCancellationRequested)
|
||||
// {
|
||||
// _cancellationTokenSource.Cancel();
|
||||
|
||||
//Wait for cancellation
|
||||
WaitHandle.WaitAny(new[] { _cancellationTokenSource.Token.WaitHandle });
|
||||
}
|
||||
// //Wait for cancellation
|
||||
// WaitHandle.WaitAny(new[] { _cancellationTokenSource.Token.WaitHandle });
|
||||
// }
|
||||
base.Unload();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user