Successfully playing a song in a party with one member
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Aurora.Models.Media
|
||||
{
|
||||
@ -19,9 +20,10 @@ namespace Aurora.Models.Media
|
||||
|
||||
#endregion Properties
|
||||
|
||||
public virtual void Load()
|
||||
public virtual Task Load()
|
||||
{
|
||||
_loaded = true;
|
||||
return Task.FromResult(default(object));
|
||||
}
|
||||
|
||||
public virtual void Unload()
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Aurora.Models.Media
|
||||
{
|
||||
@ -26,7 +27,7 @@ namespace Aurora.Models.Media
|
||||
/// <summary>
|
||||
/// Override load method.
|
||||
/// </summary>
|
||||
public override void Load()
|
||||
public override async Task Load()
|
||||
{
|
||||
if (this.DataStream != null)
|
||||
{
|
||||
@ -34,7 +35,7 @@ namespace Aurora.Models.Media
|
||||
DataStream = null;
|
||||
}
|
||||
this.DataStream = System.IO.File.OpenRead(File.FullName);
|
||||
base.Load();
|
||||
await base.Load();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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