diff --git a/Aurora/Backend/Models/Media/AudioMetadata.cs b/Aurora/Backend/Models/Media/AudioMetadata.cs
new file mode 100644
index 0000000..6410c0c
--- /dev/null
+++ b/Aurora/Backend/Models/Media/AudioMetadata.cs
@@ -0,0 +1,35 @@
+using System;
+
+namespace Aurora.Backend.Models.Media
+{
+ public class AudioMetadata : BaseMetadata
+ {
+ public void AutioMetadata()
+ {
+ }
+
+ ///
+ /// The title of the song.
+ ///
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// The artist of the song.
+ ///
+ ///
+ public string Artist { get; set; }
+
+ ///
+ /// The album from which the song belongs.
+ ///
+ ///
+ public string Album { get; set; }
+
+ ///
+ /// The duration of the song.
+ ///
+ ///
+ public string Duration { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Aurora/Backend/Models/BaseMedia.cs b/Aurora/Backend/Models/Media/BaseMedia.cs
similarity index 50%
rename from Aurora/Backend/Models/BaseMedia.cs
rename to Aurora/Backend/Models/Media/BaseMedia.cs
index 1175bc6..97a2c27 100644
--- a/Aurora/Backend/Models/BaseMedia.cs
+++ b/Aurora/Backend/Models/Media/BaseMedia.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
-namespace Aurora.Backend.Models
+namespace Aurora.Backend.Models.Media
{
public abstract class BaseMedia
{
@@ -17,36 +17,6 @@ namespace Aurora.Backend.Models
#region Properties
public string Id { get; private set; }
- ///
- /// The title of the song.
- ///
- ///
- public string Title { get; set; }
-
- ///
- /// The artist of the song.
- ///
- ///
- public string Artist { get; set; }
-
- ///
- /// The album from which the song belongs.
- ///
- ///
- public string Album { get; set; }
-
- ///
- /// The duration of the song.
- ///
- ///
- public string Duration { get; set; }
-
- ///
- /// Extra data associated with a song.
- ///
- ///
- public object Metadata { get; set; }
-
#endregion Properties
public virtual void Load()
@@ -59,6 +29,9 @@ namespace Aurora.Backend.Models
_loaded = false;
}
+ public abstract MediaTypeEnum MediaType { get; }
+
+
///
/// Gets or sets the data stream that holds the song.
///
@@ -67,10 +40,6 @@ namespace Aurora.Backend.Models
{
get
{
- //if (!_loaded)
- //{
- // throw new InvalidOperationException("Must be loaded first");
- //}
return _stream;
}
protected set
@@ -81,7 +50,5 @@ namespace Aurora.Backend.Models
}
}
}
-
}
-
}
diff --git a/Aurora/Backend/Models/Media/BaseMetadata.cs b/Aurora/Backend/Models/Media/BaseMetadata.cs
new file mode 100644
index 0000000..328cb9b
--- /dev/null
+++ b/Aurora/Backend/Models/Media/BaseMetadata.cs
@@ -0,0 +1,17 @@
+using System;
+namespace Aurora.Backend.Models.Media
+{
+ public class BaseMetadata
+ {
+ public BaseMetadata()
+ {
+ }
+
+ ///
+ /// Extra data associated with a song.
+ ///
+ ///
+ public object ExtraData { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/Aurora/Backend/Models/LocalAudio.cs b/Aurora/Backend/Models/Media/LocalAudio.cs
similarity index 60%
rename from Aurora/Backend/Models/LocalAudio.cs
rename to Aurora/Backend/Models/Media/LocalAudio.cs
index 4198e0f..735c43f 100644
--- a/Aurora/Backend/Models/LocalAudio.cs
+++ b/Aurora/Backend/Models/Media/LocalAudio.cs
@@ -1,18 +1,26 @@
using System;
using System.IO;
-namespace Aurora.Backend.Models
+namespace Aurora.Backend.Models.Media
{
public class LocalAudio : BaseMedia
{
public LocalAudio(FileInfo fileInfo)
{
File = fileInfo;
+ LoadMetadata();
}
#region Properties
public FileInfo File { get; private set; }
+ public AudioMetadata Metadata { get; private set; }
+
+ public override MediaTypeEnum MediaType
+ {
+ get { return MediaTypeEnum.Audio; }
+ }
+
#endregion Properties
///
@@ -41,5 +49,18 @@ namespace Aurora.Backend.Models
}
base.Unload();
}
+
+ private void LoadMetadata()
+ {
+ TagLib.File tagFile = TagLib.File.Create(File.FullName);
+
+ Metadata = new AudioMetadata()
+ {
+ Title = tagFile.Tag.Title,
+ Album = tagFile.Tag.Album,
+ Artist = tagFile.Tag.FirstAlbumArtist,
+ ExtraData = tagFile.Tag
+ };
+ }
}
}
\ No newline at end of file
diff --git a/Aurora/Backend/Models/Media/MediaTypeEnum.cs b/Aurora/Backend/Models/Media/MediaTypeEnum.cs
new file mode 100644
index 0000000..10cfc65
--- /dev/null
+++ b/Aurora/Backend/Models/Media/MediaTypeEnum.cs
@@ -0,0 +1,9 @@
+using System;
+namespace Aurora.Backend.Models.Media
+{
+ public enum MediaTypeEnum
+ {
+ Audio,
+ Video,
+ }
+}
\ No newline at end of file
diff --git a/Aurora/Backend/Services/LibraryService.cs b/Aurora/Backend/Services/LibraryService.cs
index dbdbd95..30a03eb 100644
--- a/Aurora/Backend/Services/LibraryService.cs
+++ b/Aurora/Backend/Services/LibraryService.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
-using Aurora.Backend.Models;
+using Aurora.Backend.Models.Media;
using Aurora.Backend.Utils;
namespace Aurora.Backend.Services
@@ -14,7 +14,6 @@ namespace Aurora.Backend.Services
private string _extensions = ".wav,.mp3,.aiff,.flac,.m4a,.m4b,.wma";
private Dictionary _library;
-
#endregion Fields
public LibraryService()
@@ -50,13 +49,7 @@ namespace Aurora.Backend.Services
{
TagLib.File tagFile = TagLib.File.Create(file.FullName);
- BaseMedia song = new LocalAudio(file)
- {
- Title = tagFile.Tag.Title,
- Album = tagFile.Tag.Album,
- Artist = tagFile.Tag.FirstAlbumArtist
- };
-
+ BaseMedia song = new LocalAudio(file);
_library.Add(song.Id, song);
}
}
diff --git a/Aurora/Backend/Services/PlayerService/PlayerService.cs b/Aurora/Backend/Services/PlayerService/PlayerService.cs
index c92cd87..4fd344d 100644
--- a/Aurora/Backend/Services/PlayerService/PlayerService.cs
+++ b/Aurora/Backend/Services/PlayerService/PlayerService.cs
@@ -1,5 +1,5 @@
using System;
-using Aurora.Backend.Models;
+using Aurora.Backend.Models.Media;
using LibVLCSharp.Shared;
namespace Aurora.Backend.Services.PlayerService
@@ -54,10 +54,10 @@ namespace Aurora.Backend.Services.PlayerService
///
public void Play()
{
- PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Playing));
+ PlaybackState oldState = _state;
_state = PlaybackState.Playing;
_mediaPlayer.Play();
-
+ PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(oldState, _state));
}
///
@@ -65,9 +65,10 @@ namespace Aurora.Backend.Services.PlayerService
///
public void Pause()
{
- PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Buffering));
+ PlaybackState oldState = _state;
_state = PlaybackState.Buffering;
_mediaPlayer.Pause();
+ PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(oldState, _state));
}
///
@@ -75,9 +76,10 @@ namespace Aurora.Backend.Services.PlayerService
///
public void Stop()
{
- PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Stopped));
+ PlaybackState oldState = _state;
_state = PlaybackState.Stopped;
_mediaPlayer.Stop();
+ PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(oldState, _state));
}
public void Enqueue(BaseMedia song)
diff --git a/Aurora/Frontend/Components/MediaPlayer/Player.xaml b/Aurora/Frontend/Components/MediaPlayer/Player.xaml
index f242330..1c92205 100644
--- a/Aurora/Frontend/Components/MediaPlayer/Player.xaml
+++ b/Aurora/Frontend/Components/MediaPlayer/Player.xaml
@@ -1,10 +1,42 @@
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Aurora/Frontend/Views/MainView/MainView.xaml.cs b/Aurora/Frontend/Views/MainView/MainView.xaml.cs
index 5be711d..e476054 100644
--- a/Aurora/Frontend/Views/MainView/MainView.xaml.cs
+++ b/Aurora/Frontend/Views/MainView/MainView.xaml.cs
@@ -17,12 +17,11 @@ namespace Aurora.Frontend.Views.Main
BindingContext = new MainViewModel();
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
- //Set initial view from first item in list
- ObservableCollection screenList = (ObservableCollection)MasterPage.ListView.ItemsSource;
- var view = (View)Activator.CreateInstance(screenList.FirstOrDefault().FirstOrDefault().TargetType);
-
- ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
- viewContent.Content = view;
+ Appearing += OnAppearing;
+ }
+ ~MainView()
+ {
+ Appearing -= OnAppearing;
}
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
@@ -38,6 +37,23 @@ namespace Aurora.Frontend.Views.Main
MasterPage.ListView.SelectedItem = null;
}
+
+ ///
+ /// Event handler for page appearing.
+ ///
+ /// The object that fired the event.
+ /// The event arguments
+ private void OnAppearing(object sender, EventArgs args)
+ {
+ //Set initial view from first item in list
+ ObservableCollection screenList = (ObservableCollection)MasterPage.ListView.ItemsSource;
+ var view = (View)Activator.CreateInstance(screenList.FirstOrDefault().FirstOrDefault().TargetType);
+
+ ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
+ viewContent.Content = view;
+
+ MasterPage.ListView.SelectedItem = screenList.FirstOrDefault();
+ }
}
}
diff --git a/Aurora/Frontend/Views/MainView/PageContainer.xaml b/Aurora/Frontend/Views/MainView/PageContainer.xaml
index 5f95fb4..79ad17e 100644
--- a/Aurora/Frontend/Views/MainView/PageContainer.xaml
+++ b/Aurora/Frontend/Views/MainView/PageContainer.xaml
@@ -1,9 +1,26 @@
-
+
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Aurora/Frontend/Views/Songs/SongsView.xaml b/Aurora/Frontend/Views/Songs/SongsView.xaml
index a3b2370..e29e18d 100644
--- a/Aurora/Frontend/Views/Songs/SongsView.xaml
+++ b/Aurora/Frontend/Views/Songs/SongsView.xaml
@@ -1,50 +1,66 @@
-
+
-
+
-
-
-
-
+
-
+
15
13
20
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
#F2F2F2
#FFFFFF
-
-
-
+
\ No newline at end of file
diff --git a/Aurora/Frontend/Views/Songs/SongsViewModel.cs b/Aurora/Frontend/Views/Songs/SongsViewModel.cs
index 4e436ba..f7b4028 100644
--- a/Aurora/Frontend/Views/Songs/SongsViewModel.cs
+++ b/Aurora/Frontend/Views/Songs/SongsViewModel.cs
@@ -1,5 +1,5 @@
using System.Collections.ObjectModel;
-using Aurora.Backend.Models;
+using Aurora.Backend.Models.Media;
using Aurora.Backend.Services;
using Aurora.Backend.Services.PlayerService;
using Xamarin.Forms;