diff --git a/Aurora/Aurora.csproj b/Aurora/Aurora.csproj
index 122adea..51e70d9 100644
--- a/Aurora/Aurora.csproj
+++ b/Aurora/Aurora.csproj
@@ -33,6 +33,7 @@
+
diff --git a/Aurora/Backend/Models/BaseSong.cs b/Aurora/Backend/Models/BaseSong.cs
index ca2156d..935029a 100644
--- a/Aurora/Backend/Models/BaseSong.cs
+++ b/Aurora/Backend/Models/BaseSong.cs
@@ -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
///
public object Metadata { get; set; }
-
#endregion Properties
- #region Methods
- ///
- /// Play this instance.
- ///
- public abstract void Play();
+ public virtual void Load()
+ {
+ _loaded = true;
+ }
+
+ public virtual void Unload()
+ {
+ _loaded = false;
+ }
+
+ ///
+ /// Gets or sets the data stream that holds the song.
+ ///
+ /// The data stream.
+ public Stream DataStream
+ {
+ get
+ {
+ //if (!_loaded)
+ //{
+ // throw new InvalidOperationException("Must be loaded first");
+ //}
+ return _stream;
+ }
+ protected set
+ {
+ if (value != _stream)
+ {
+ _stream = value;
+ }
+ }
+ }
- #endregion
}
}
diff --git a/Aurora/Backend/Models/LocalSong.cs b/Aurora/Backend/Models/LocalSong.cs
index 21405bb..502344c 100644
--- a/Aurora/Backend/Models/LocalSong.cs
+++ b/Aurora/Backend/Models/LocalSong.cs
@@ -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();
+ }
}
}
\ No newline at end of file
diff --git a/Aurora/Frontend/Views/BaseViewModel.cs b/Aurora/Frontend/Views/BaseViewModel.cs
index 76b6588..f30f12d 100644
--- a/Aurora/Frontend/Views/BaseViewModel.cs
+++ b/Aurora/Frontend/Views/BaseViewModel.cs
@@ -4,13 +4,23 @@ using System.Runtime.CompilerServices;
namespace Aurora.Frontend.Views
{
- public class BaseViewModel
+ public class BaseViewModel : INotifyPropertyChanged
{
public BaseViewModel()
{
}
#region INotifyPropertyChanged Implementation
+ public bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null)
+ {
+ if (Object.Equals(storage, value))
+ return false;
+
+ storage = value;
+ OnPropertyChanged(propertyName);
+ return true;
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
diff --git a/Aurora/Frontend/Views/Songs/SongsView.xaml b/Aurora/Frontend/Views/Songs/SongsView.xaml
index 5a48407..ee475b6 100644
--- a/Aurora/Frontend/Views/Songs/SongsView.xaml
+++ b/Aurora/Frontend/Views/Songs/SongsView.xaml
@@ -1,11 +1,16 @@
+
+
+
+
+ RowHeight="30" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8" >
@@ -18,7 +23,14 @@
-
+
+
+
+
+
+
+
+
diff --git a/Aurora/Frontend/Views/Songs/SongsView.xaml.cs b/Aurora/Frontend/Views/Songs/SongsView.xaml.cs
index 859ee32..24e46e8 100644
--- a/Aurora/Frontend/Views/Songs/SongsView.xaml.cs
+++ b/Aurora/Frontend/Views/Songs/SongsView.xaml.cs
@@ -10,7 +10,6 @@ namespace Aurora.Frontend.Views.Songs
public SongsView()
{
InitializeComponent();
- BindingContext = new SongsViewModel();
}
}
}
diff --git a/Aurora/Frontend/Views/Songs/SongsViewModel.cs b/Aurora/Frontend/Views/Songs/SongsViewModel.cs
index b650d06..18b4506 100644
--- a/Aurora/Frontend/Views/Songs/SongsViewModel.cs
+++ b/Aurora/Frontend/Views/Songs/SongsViewModel.cs
@@ -1,6 +1,8 @@
using System.Collections.ObjectModel;
using Aurora.Backend.Models;
using Aurora.Backend.Services;
+using Aurora.Backend.Services.PlayerService;
+using Xamarin.Forms;
namespace Aurora.Frontend.Views.Songs
{
@@ -16,6 +18,7 @@ namespace Aurora.Frontend.Views.Songs
public SongsViewModel()
{
_songsList = new ObservableCollection();
+ PlayCommand = new Command(PlayExecute);
Initialize();
}
@@ -25,29 +28,17 @@ namespace Aurora.Frontend.Views.Songs
public ObservableCollection SongsList
{
get { return _songsList; }
- set
- {
- if (value != _songsList)
- {
- _songsList = value;
- OnPropertyChanged("SongList");
- }
- }
+ set { SetProperty(ref _songsList, value); }
}
public BaseSong SelectedSong
{
get { return _selectedSong; }
- set
- {
- if (value != _selectedSong)
- {
- _selectedSong = value;
- OnPropertyChanged("SelectedSong");
- }
- }
+ set { SetProperty(ref _selectedSong, value); }
}
+ public Command PlayCommand { get; private set; }
+
#endregion Properties
#region Methods