See commit description for changes
Added PageContainer to dynamically load pages within the main content. Added player component to control music playback(Half functional). Added playback changed event not the player service.
This commit is contained in:
parent
2dbe9cead9
commit
93be6dc100
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -10,7 +10,7 @@
|
|||||||
"type": "mono",
|
"type": "mono",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"address": "localhost",
|
"address": "localhost",
|
||||||
"port": 55555
|
"port": 55555,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -3,12 +3,12 @@ using System.IO;
|
|||||||
|
|
||||||
namespace Aurora.Backend.Models
|
namespace Aurora.Backend.Models
|
||||||
{
|
{
|
||||||
public abstract class BaseSong
|
public abstract class BaseMedia
|
||||||
{
|
{
|
||||||
private bool _loaded;
|
private bool _loaded;
|
||||||
private Stream _stream;
|
private Stream _stream;
|
||||||
|
|
||||||
public BaseSong()
|
public BaseMedia()
|
||||||
{
|
{
|
||||||
_loaded = false;
|
_loaded = false;
|
||||||
Id = Guid.NewGuid().ToString();
|
Id = Guid.NewGuid().ToString();
|
@ -3,9 +3,9 @@ using System.IO;
|
|||||||
|
|
||||||
namespace Aurora.Backend.Models
|
namespace Aurora.Backend.Models
|
||||||
{
|
{
|
||||||
public class LocalSong : BaseSong
|
public class LocalAudio : BaseMedia
|
||||||
{
|
{
|
||||||
public LocalSong(FileInfo fileInfo)
|
public LocalAudio(FileInfo fileInfo)
|
||||||
{
|
{
|
||||||
File = fileInfo;
|
File = fileInfo;
|
||||||
}
|
}
|
||||||
@ -15,6 +15,9 @@ namespace Aurora.Backend.Models
|
|||||||
|
|
||||||
#endregion Properties
|
#endregion Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override load method.
|
||||||
|
/// </summary>
|
||||||
public override void Load()
|
public override void Load()
|
||||||
{
|
{
|
||||||
if (this.DataStream != null)
|
if (this.DataStream != null)
|
||||||
@ -26,6 +29,9 @@ namespace Aurora.Backend.Models
|
|||||||
base.Load();
|
base.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override unload method
|
||||||
|
/// </summary>
|
||||||
public override void Unload()
|
public override void Unload()
|
||||||
{
|
{
|
||||||
if (this.DataStream != null)
|
if (this.DataStream != null)
|
@ -12,14 +12,14 @@ namespace Aurora.Backend.Services
|
|||||||
#region Fields
|
#region Fields
|
||||||
private string _pathName = "/Users/brandonwatson/Music/iTunes/iTunes Media/Music";
|
private string _pathName = "/Users/brandonwatson/Music/iTunes/iTunes Media/Music";
|
||||||
private string _extensions = ".wav,.mp3,.aiff,.flac,.m4a,.m4b,.wma";
|
private string _extensions = ".wav,.mp3,.aiff,.flac,.m4a,.m4b,.wma";
|
||||||
private Dictionary<string, BaseSong> _library;
|
private Dictionary<string, BaseMedia> _library;
|
||||||
|
|
||||||
|
|
||||||
#endregion Fields
|
#endregion Fields
|
||||||
|
|
||||||
public LibraryService()
|
public LibraryService()
|
||||||
{
|
{
|
||||||
_library = new Dictionary<string, BaseSong>();
|
_library = new Dictionary<string, BaseMedia>();
|
||||||
LoadLibrary();
|
LoadLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,10 +27,10 @@ namespace Aurora.Backend.Services
|
|||||||
/// Gets the songs.
|
/// Gets the songs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The songs.</returns>
|
/// <returns>The songs.</returns>
|
||||||
public ObservableCollection<BaseSong> GetLibrary()
|
public ObservableCollection<BaseMedia> GetLibrary()
|
||||||
{
|
{
|
||||||
ObservableCollection<BaseSong> collection = new ObservableCollection<BaseSong>();
|
ObservableCollection<BaseMedia> collection = new ObservableCollection<BaseMedia>();
|
||||||
foreach (KeyValuePair<string, BaseSong> pair in _library)
|
foreach (KeyValuePair<string, BaseMedia> pair in _library)
|
||||||
{
|
{
|
||||||
collection.Add(pair.Value);
|
collection.Add(pair.Value);
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ namespace Aurora.Backend.Services
|
|||||||
{
|
{
|
||||||
TagLib.File tagFile = TagLib.File.Create(file.FullName);
|
TagLib.File tagFile = TagLib.File.Create(file.FullName);
|
||||||
|
|
||||||
BaseSong song = new LocalSong(file)
|
BaseMedia song = new LocalAudio(file)
|
||||||
{
|
{
|
||||||
Title = tagFile.Tag.Title,
|
Title = tagFile.Tag.Title,
|
||||||
Album = tagFile.Tag.Album,
|
Album = tagFile.Tag.Album,
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Aurora.Backend.Models;
|
|
||||||
using LibVLCSharp.Shared;
|
|
||||||
|
|
||||||
namespace Aurora.Backend.Services
|
|
||||||
{
|
|
||||||
public class PlayerService : BaseService<PlayerService>
|
|
||||||
{
|
|
||||||
public PlayerService()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Play(BaseSong song)
|
|
||||||
{
|
|
||||||
using (var libVLC = new LibVLC())
|
|
||||||
{
|
|
||||||
song.Load();
|
|
||||||
var media = new Media(libVLC, song.DataStream);
|
|
||||||
using (var mp = new MediaPlayer(media))
|
|
||||||
{
|
|
||||||
media.Dispose();
|
|
||||||
mp.Play();
|
|
||||||
Console.ReadKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
song.Unload();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
9
Aurora/Backend/Services/PlayerService/PlaybackState.cs
Normal file
9
Aurora/Backend/Services/PlayerService/PlaybackState.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
public enum PlaybackState
|
||||||
|
{
|
||||||
|
Playing,
|
||||||
|
Stopped,
|
||||||
|
Buffering,
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Aurora.Backend.Services.PlayerService
|
||||||
|
{
|
||||||
|
public delegate void PlaybackStateChangedEventHandler(object source, PlaybackStateChangedEventArgs e);
|
||||||
|
|
||||||
|
public class PlaybackStateChangedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public PlaybackState OldState { get; }
|
||||||
|
public PlaybackState NewState { get; }
|
||||||
|
|
||||||
|
public PlaybackStateChangedEventArgs(PlaybackState oldState, PlaybackState newState)
|
||||||
|
{
|
||||||
|
OldState = oldState;
|
||||||
|
NewState = newState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
116
Aurora/Backend/Services/PlayerService/PlayerService.cs
Normal file
116
Aurora/Backend/Services/PlayerService/PlayerService.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using System;
|
||||||
|
using Aurora.Backend.Models;
|
||||||
|
using LibVLCSharp.Shared;
|
||||||
|
|
||||||
|
namespace Aurora.Backend.Services.PlayerService
|
||||||
|
{
|
||||||
|
public class PlayerService : BaseService<PlayerService>
|
||||||
|
{
|
||||||
|
private BaseMedia _currentMedia;
|
||||||
|
private MediaPlayer _mediaPlayer;
|
||||||
|
private LibVLC _libvlc;
|
||||||
|
private PlaybackState _state;
|
||||||
|
|
||||||
|
public PlayerService()
|
||||||
|
{
|
||||||
|
_libvlc = new LibVLC();
|
||||||
|
_state = PlaybackState.Stopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event handler for changing playback states.
|
||||||
|
/// </summary>
|
||||||
|
public event PlaybackStateChangedEventHandler PlaybackStateChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The state of playback
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public PlaybackState PlaybackState
|
||||||
|
{
|
||||||
|
get { return _state; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load media into the media player.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="media">Media to load</param>
|
||||||
|
public void LoadMedia(BaseMedia media)
|
||||||
|
{
|
||||||
|
if (_state == PlaybackState.Playing || _state == PlaybackState.Buffering)
|
||||||
|
{
|
||||||
|
Unload();
|
||||||
|
}
|
||||||
|
_currentMedia = media;
|
||||||
|
_currentMedia.Load();
|
||||||
|
var md = new Media(_libvlc, _currentMedia.DataStream);
|
||||||
|
_mediaPlayer = new MediaPlayer(md);
|
||||||
|
_mediaPlayer.Stopped += OnStopped;
|
||||||
|
md.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Play currently loaded media.
|
||||||
|
/// </summary>
|
||||||
|
public void Play()
|
||||||
|
{
|
||||||
|
PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Playing));
|
||||||
|
_state = PlaybackState.Playing;
|
||||||
|
_mediaPlayer.Play();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pause currently loaded media.
|
||||||
|
/// </summary>
|
||||||
|
public void Pause()
|
||||||
|
{
|
||||||
|
PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Buffering));
|
||||||
|
_state = PlaybackState.Buffering;
|
||||||
|
_mediaPlayer.Pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop currently loaded media.
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Stopped));
|
||||||
|
_state = PlaybackState.Stopped;
|
||||||
|
_mediaPlayer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Enqueue(BaseMedia song)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dequeue(BaseMedia song)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unload currently loaded media.
|
||||||
|
/// </summary>
|
||||||
|
private void Unload()
|
||||||
|
{
|
||||||
|
_currentMedia.Unload();
|
||||||
|
_mediaPlayer.Media = null;
|
||||||
|
_mediaPlayer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event fired when currently loaded media player stops.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
private void OnStopped(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
PlaybackStateChanged.Invoke(this, new PlaybackStateChangedEventArgs(_state, PlaybackState.Stopped));
|
||||||
|
_state = PlaybackState.Stopped;
|
||||||
|
this.Unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
10
Aurora/Frontend/Components/MediaPlayer/Player.xaml
Normal file
10
Aurora/Frontend/Components/MediaPlayer/Player.xaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Components.MediaPlayer.Player">
|
||||||
|
<ContentView.Content>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<Button Text="Previous" Command="{Binding PreviousCommand}" WidthRequest="100" HeightRequest="50"/>
|
||||||
|
<Button Text="{Binding PlayButtonText}" Command="{Binding PlayCommand}" WidthRequest="100" HeightRequest="50"/>
|
||||||
|
<Button Text="Next" Command="{Binding NextCommand}" WidthRequest="100" HeightRequest="50"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentView.Content>
|
||||||
|
</ContentView>
|
@ -2,12 +2,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Aurora.Frontend.Components.MusicPlayer
|
namespace Aurora.Frontend.Components.MediaPlayer
|
||||||
{
|
{
|
||||||
public partial class Player : ContentView
|
public partial class Player : ContentView
|
||||||
{
|
{
|
||||||
public Player()
|
public Player()
|
||||||
{
|
{
|
||||||
|
BindingContext = new PlayerViewModel();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
108
Aurora/Frontend/Components/MediaPlayer/PlayerViewModel.cs
Normal file
108
Aurora/Frontend/Components/MediaPlayer/PlayerViewModel.cs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Aurora.Frontend.Views;
|
||||||
|
using Aurora.Backend.Services.PlayerService;
|
||||||
|
|
||||||
|
namespace Aurora.Frontend.Components.MediaPlayer
|
||||||
|
{
|
||||||
|
public class PlayerViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
PlayerService _playerService;
|
||||||
|
public PlayerViewModel()
|
||||||
|
{
|
||||||
|
_playerService = PlayerService.Instance;
|
||||||
|
_playerService.PlaybackStateChanged += OnPlaybackStateChanged;
|
||||||
|
|
||||||
|
PlayCommand = new Command(OnPlayExecute, CanPlayExecute);
|
||||||
|
PreviousCommand = new Command(OnPreviousExecute, CanPreviousExecute);
|
||||||
|
NextCommand = new Command(OnNextExecute, CanNextExecute);
|
||||||
|
}
|
||||||
|
|
||||||
|
~PlayerViewModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
public Command PlayCommand { get; private set; }
|
||||||
|
public Command NextCommand { get; private set; }
|
||||||
|
public Command PreviousCommand { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public string PlayButtonText
|
||||||
|
{
|
||||||
|
get { return PlayerService.Instance.PlaybackState == PlaybackState.Buffering ? "Play" : "Pause"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Properties
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
public bool CanPreviousExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void OnPreviousExecute()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanPlayExecute()
|
||||||
|
{
|
||||||
|
switch (_playerService.PlaybackState)
|
||||||
|
{
|
||||||
|
case PlaybackState.Buffering:
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case PlaybackState.Playing:
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case PlaybackState.Stopped:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPlayExecute()
|
||||||
|
{
|
||||||
|
switch (_playerService.PlaybackState)
|
||||||
|
{
|
||||||
|
case PlaybackState.Buffering:
|
||||||
|
{
|
||||||
|
_playerService.Play();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PlaybackState.Playing:
|
||||||
|
{
|
||||||
|
_playerService.Pause();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanNextExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnNextExecute()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion public Methods
|
||||||
|
|
||||||
|
#region EventHandlers
|
||||||
|
public void OnPlaybackStateChanged(object sender, PlaybackStateChangedEventArgs args)
|
||||||
|
{
|
||||||
|
OnPropertyChanged("PlayButtonText");
|
||||||
|
PlayCommand.ChangeCanExecute();
|
||||||
|
NextCommand.ChangeCanExecute();
|
||||||
|
PreviousCommand.ChangeCanExecute();
|
||||||
|
}
|
||||||
|
#endregion EventHandlers
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Components.MusicPlayer.Player">
|
|
||||||
<ContentView.Content>
|
|
||||||
</ContentView.Content>
|
|
||||||
</ContentView>
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Albums.AlbumsView">
|
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Albums.AlbumsView">
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
<Label Text="Albums" />
|
<Label Text="Albums" />
|
||||||
</ContentPage.Content>
|
</ContentPage.Content>
|
||||||
</ContentPage>
|
</ContentView>
|
||||||
|
@ -5,7 +5,7 @@ using Xamarin.Forms;
|
|||||||
|
|
||||||
namespace Aurora.Frontend.Views.Albums
|
namespace Aurora.Frontend.Views.Albums
|
||||||
{
|
{
|
||||||
public partial class AlbumsView : ContentPage
|
public partial class AlbumsView : ContentView
|
||||||
{
|
{
|
||||||
public AlbumsView()
|
public AlbumsView()
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Artists.ArtistsView">
|
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Artists.ArtistsView">
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
</ContentPage.Content>
|
</ContentPage.Content>
|
||||||
</ContentPage>
|
</ContentView>
|
||||||
|
@ -5,7 +5,7 @@ using Xamarin.Forms;
|
|||||||
|
|
||||||
namespace Aurora.Frontend.Views.Artists
|
namespace Aurora.Frontend.Views.Artists
|
||||||
{
|
{
|
||||||
public partial class ArtistsView : ContentPage
|
public partial class ArtistsView : ContentView
|
||||||
{
|
{
|
||||||
public ArtistsView()
|
public ArtistsView()
|
||||||
{
|
{
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:views="clr-namespace:Aurora.Frontend.Views.Songs"
|
xmlns:views="clr-namespace:Aurora.Frontend.Views.MainView"
|
||||||
xmlns:navigation="clr-namespace:Aurora.Frontend.Components.NavigationMenu"
|
xmlns:navigation="clr-namespace:Aurora.Frontend.Components.NavigationMenu"
|
||||||
x:Class="Aurora.Frontend.Views.Main.MainView"
|
x:Class="Aurora.Frontend.Views.Main.MainView"
|
||||||
MasterBehavior="Split">
|
MasterBehavior="Split">
|
||||||
|
|
||||||
<MasterDetailPage.Master>
|
<MasterDetailPage.Master>
|
||||||
<navigation:NavigationMenu x:Name="MasterPage" Items="{Binding Pages}"/>
|
<navigation:NavigationMenu x:Name="MasterPage" Items="{Binding Pages}"/>
|
||||||
</MasterDetailPage.Master>
|
</MasterDetailPage.Master>
|
||||||
|
|
||||||
<MasterDetailPage.Detail>
|
<MasterDetailPage.Detail>
|
||||||
<NavigationPage>
|
<NavigationPage>
|
||||||
<x:Arguments>
|
<x:Arguments>
|
||||||
<views:SongsView />
|
<views:PageContainer x:Name="ContentPage" />
|
||||||
</x:Arguments>
|
</x:Arguments>
|
||||||
</NavigationPage>
|
</NavigationPage>
|
||||||
</MasterDetailPage.Detail>
|
</MasterDetailPage.Detail>
|
||||||
|
|
||||||
</MasterDetailPage>
|
</MasterDetailPage>
|
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
using Aurora.Frontend.Components.NavigationMenu;
|
using Aurora.Frontend.Components.NavigationMenu;
|
||||||
using Aurora.Frontend.Views.MainView;
|
using Aurora.Frontend.Views.MainView;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
namespace Aurora.Frontend.Views.Main
|
namespace Aurora.Frontend.Views.Main
|
||||||
{
|
{
|
||||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
public partial class MainView : MasterDetailPage
|
public partial class MainView : MasterDetailPage
|
||||||
{
|
{
|
||||||
@ -15,6 +16,13 @@ namespace Aurora.Frontend.Views.Main
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BindingContext = new MainViewModel();
|
BindingContext = new MainViewModel();
|
||||||
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
|
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
|
||||||
|
|
||||||
|
//Set initial view from first item in list
|
||||||
|
ObservableCollection<NavigationGroupItem> screenList = (ObservableCollection<NavigationGroupItem>)MasterPage.ListView.ItemsSource;
|
||||||
|
var view = (View)Activator.CreateInstance(screenList.FirstOrDefault().FirstOrDefault().TargetType);
|
||||||
|
|
||||||
|
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
|
||||||
|
viewContent.Content = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||||
@ -23,10 +31,10 @@ namespace Aurora.Frontend.Views.Main
|
|||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var page = (Page)Activator.CreateInstance(item.TargetType);
|
var view = (View)Activator.CreateInstance(item.TargetType);
|
||||||
page.Title = item.Title;
|
|
||||||
|
|
||||||
Detail = new NavigationPage(page);
|
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
|
||||||
|
viewContent.Content = view;
|
||||||
|
|
||||||
MasterPage.ListView.SelectedItem = null;
|
MasterPage.ListView.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
9
Aurora/Frontend/Views/MainView/PageContainer.xaml
Normal file
9
Aurora/Frontend/Views/MainView/PageContainer.xaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:components="clr-namespace:Aurora.Frontend.Components" xmlns:mp="clr-namespace:Aurora.Frontend.Components.MediaPlayer" x:Class="Aurora.Frontend.Views.MainView.PageContainer">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<ContentPresenter x:Name="ViewContent"/>
|
||||||
|
<mp:Player HorizontalOptions="CenterAndExpand" VerticalOptions="End" HeightRequest="200"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
15
Aurora/Frontend/Views/MainView/PageContainer.xaml.cs
Normal file
15
Aurora/Frontend/Views/MainView/PageContainer.xaml.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Aurora.Frontend.Views.MainView
|
||||||
|
{
|
||||||
|
public partial class PageContainer : ContentPage
|
||||||
|
{
|
||||||
|
public PageContainer()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:songs="clr-namespace:Aurora.Frontend.Views.Songs"
|
xmlns:songs="clr-namespace:Aurora.Frontend.Views.Songs"
|
||||||
xmlns:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
|
xmlns:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
|
||||||
@ -47,4 +47,4 @@
|
|||||||
|
|
||||||
</dg:DataGrid>
|
</dg:DataGrid>
|
||||||
</ContentPage.Content>
|
</ContentPage.Content>
|
||||||
</ContentPage>
|
</ContentView>
|
||||||
|
@ -5,7 +5,7 @@ using Xamarin.Forms;
|
|||||||
|
|
||||||
namespace Aurora.Frontend.Views.Songs
|
namespace Aurora.Frontend.Views.Songs
|
||||||
{
|
{
|
||||||
public partial class SongsView : ContentPage
|
public partial class SongsView : ContentView
|
||||||
{
|
{
|
||||||
public SongsView()
|
public SongsView()
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using Aurora.Backend.Models;
|
using Aurora.Backend.Models;
|
||||||
using Aurora.Backend.Services;
|
using Aurora.Backend.Services;
|
||||||
|
using Aurora.Backend.Services.PlayerService;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Aurora.Frontend.Views.Songs
|
namespace Aurora.Frontend.Views.Songs
|
||||||
@ -8,15 +9,15 @@ namespace Aurora.Frontend.Views.Songs
|
|||||||
public class SongsViewModel : BaseViewModel
|
public class SongsViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
private ObservableCollection<BaseSong> _songsList;
|
private ObservableCollection<BaseMedia> _songsList;
|
||||||
private BaseSong _selectedSong;
|
private BaseMedia _selectedSong;
|
||||||
|
|
||||||
#endregion Fields
|
#endregion Fields
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
public SongsViewModel()
|
public SongsViewModel()
|
||||||
{
|
{
|
||||||
_songsList = new ObservableCollection<BaseSong>();
|
_songsList = new ObservableCollection<BaseMedia>();
|
||||||
PlayCommand = new Command(PlayExecute);
|
PlayCommand = new Command(PlayExecute);
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
@ -24,13 +25,13 @@ namespace Aurora.Frontend.Views.Songs
|
|||||||
#endregion Constructor
|
#endregion Constructor
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public ObservableCollection<BaseSong> SongsList
|
public ObservableCollection<BaseMedia> SongsList
|
||||||
{
|
{
|
||||||
get { return _songsList; }
|
get { return _songsList; }
|
||||||
set { SetProperty(ref _songsList, value); }
|
set { SetProperty(ref _songsList, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseSong SelectedSong
|
public BaseMedia SelectedSong
|
||||||
{
|
{
|
||||||
get { return _selectedSong; }
|
get { return _selectedSong; }
|
||||||
set { SetProperty(ref _selectedSong, value); }
|
set { SetProperty(ref _selectedSong, value); }
|
||||||
@ -49,7 +50,8 @@ namespace Aurora.Frontend.Views.Songs
|
|||||||
|
|
||||||
public void PlayExecute()
|
public void PlayExecute()
|
||||||
{
|
{
|
||||||
PlayerService.Instance.Play(_selectedSong);
|
PlayerService.Instance.LoadMedia(_selectedSong);
|
||||||
|
PlayerService.Instance.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Methods
|
#endregion Methods
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Stations.StationsView">
|
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Stations.StationsView">
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
</ContentPage.Content>
|
</ContentPage.Content>
|
||||||
</ContentPage>
|
</ContentView>
|
@ -5,7 +5,7 @@ using Xamarin.Forms;
|
|||||||
|
|
||||||
namespace Aurora.Frontend.Views.Stations
|
namespace Aurora.Frontend.Views.Stations
|
||||||
{
|
{
|
||||||
public partial class StationsView : ContentPage
|
public partial class StationsView : ContentView
|
||||||
{
|
{
|
||||||
public StationsView()
|
public StationsView()
|
||||||
{
|
{
|
||||||
|
@ -3,5 +3,12 @@
|
|||||||
{
|
{
|
||||||
"path": "."
|
"path": "."
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"settings": {
|
||||||
|
"files.exclude": {
|
||||||
|
"**/bin": true,
|
||||||
|
"**/obj": true,
|
||||||
|
"**/packages": true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user