2019-05-20 00:21:54 +00:00
|
|
|
|
using System;
|
2019-05-22 14:30:41 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
2019-05-20 00:21:54 +00:00
|
|
|
|
namespace Aurora.Backend.Models
|
2019-05-19 21:25:42 +00:00
|
|
|
|
{
|
2019-05-20 00:21:54 +00:00
|
|
|
|
public abstract class BaseSong
|
2019-05-19 21:25:42 +00:00
|
|
|
|
{
|
2019-05-22 14:30:41 +00:00
|
|
|
|
private bool _loaded;
|
|
|
|
|
private Stream _stream;
|
|
|
|
|
|
2019-05-20 00:21:54 +00:00
|
|
|
|
public BaseSong()
|
2019-05-19 21:25:42 +00:00
|
|
|
|
{
|
2019-05-22 14:30:41 +00:00
|
|
|
|
_loaded = false;
|
2019-05-20 00:21:54 +00:00
|
|
|
|
Id = Guid.NewGuid().ToString();
|
2019-05-19 21:25:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 00:21:54 +00:00
|
|
|
|
#region Properties
|
|
|
|
|
public string Id { get; private set; }
|
|
|
|
|
|
2019-05-19 21:25:42 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The title of the song.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The artist of the song.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public string Artist { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The album from which the song belongs.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public string Album { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The duration of the song.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public string Duration { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Extra data associated with a song.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public object Metadata { get; set; }
|
2019-05-20 00:21:54 +00:00
|
|
|
|
|
|
|
|
|
#endregion Properties
|
|
|
|
|
|
2019-05-22 14:30:41 +00:00
|
|
|
|
public virtual void Load()
|
|
|
|
|
{
|
|
|
|
|
_loaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Unload()
|
|
|
|
|
{
|
|
|
|
|
_loaded = false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 00:21:54 +00:00
|
|
|
|
/// <summary>
|
2019-05-22 14:30:41 +00:00
|
|
|
|
/// Gets or sets the data stream that holds the song.
|
2019-05-20 00:21:54 +00:00
|
|
|
|
/// </summary>
|
2019-05-22 14:30:41 +00:00
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-20 00:21:54 +00:00
|
|
|
|
|
2019-05-19 21:25:42 +00:00
|
|
|
|
}
|
2019-05-20 00:21:54 +00:00
|
|
|
|
|
|
|
|
|
}
|