Hooked up view with play button

Set up data structures for holding and playing music
This commit is contained in:
watsonb8
2019-05-22 10:30:41 -04:00
parent 65d56a838c
commit a4276a0d5d
7 changed files with 88 additions and 31 deletions

View File

@ -1,10 +1,16 @@
using System;
using System.IO;
namespace Aurora.Backend.Models
{
public abstract class BaseSong
{
private bool _loaded;
private Stream _stream;
public BaseSong()
{
_loaded = false;
Id = Guid.NewGuid().ToString();
}
@ -41,16 +47,41 @@ namespace Aurora.Backend.Models
/// <value></value>
public object Metadata { get; set; }
#endregion Properties
#region Methods
/// <summary>
/// Play this instance.
/// </summary>
public abstract void Play();
public virtual void Load()
{
_loaded = true;
}
public virtual void Unload()
{
_loaded = false;
}
/// <summary>
/// Gets or sets the data stream that holds the song.
/// </summary>
/// <value>The data stream.</value>
public Stream DataStream
{
get
{
//if (!_loaded)
//{
// throw new InvalidOperationException("Must be loaded first");
//}
return _stream;
}
protected set
{
if (value != _stream)
{
_stream = value;
}
}
}
#endregion
}
}

View File

@ -15,12 +15,25 @@ namespace Aurora.Backend.Models
#endregion Properties
#region Methods
public override void Play()
public override void Load()
{
throw new NotImplementedException();
if (this.DataStream != null)
{
DataStream.Close();
DataStream = null;
}
this.DataStream = System.IO.File.OpenRead(File.FullName);
base.Load();
}
#endregion Methods
public override void Unload()
{
if (this.DataStream != null)
{
DataStream.Close();
DataStream = null;
}
base.Unload();
}
}
}