2019-05-19 20:21:54 -04:00
|
|
|
|
using System.Collections.ObjectModel;
|
2019-07-05 14:17:09 -04:00
|
|
|
|
using Aurora.Models.Media;
|
|
|
|
|
using Aurora.Services;
|
|
|
|
|
using Aurora.Services.PlayerService;
|
2019-05-22 10:30:41 -04:00
|
|
|
|
using Xamarin.Forms;
|
2019-05-19 17:25:42 -04:00
|
|
|
|
|
2019-07-05 14:17:09 -04:00
|
|
|
|
namespace Aurora.Design.Views.Songs
|
2019-05-18 17:25:36 -04:00
|
|
|
|
{
|
2019-05-19 17:25:42 -04:00
|
|
|
|
public class SongsViewModel : BaseViewModel
|
2019-05-18 17:25:36 -04:00
|
|
|
|
{
|
2019-05-19 17:25:42 -04:00
|
|
|
|
#region Fields
|
2019-05-24 10:27:19 -04:00
|
|
|
|
private ObservableCollection<BaseMedia> _songsList;
|
|
|
|
|
private BaseMedia _selectedSong;
|
2019-05-19 17:25:42 -04:00
|
|
|
|
|
|
|
|
|
#endregion Fields
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
2019-05-18 17:25:36 -04:00
|
|
|
|
public SongsViewModel()
|
|
|
|
|
{
|
2019-05-24 10:27:19 -04:00
|
|
|
|
_songsList = new ObservableCollection<BaseMedia>();
|
2019-05-22 10:30:41 -04:00
|
|
|
|
PlayCommand = new Command(PlayExecute);
|
2019-05-19 17:25:42 -04:00
|
|
|
|
Initialize();
|
2019-05-18 17:25:36 -04:00
|
|
|
|
}
|
2019-05-19 17:25:42 -04:00
|
|
|
|
|
|
|
|
|
#endregion Constructor
|
|
|
|
|
|
|
|
|
|
#region Properties
|
2019-05-24 10:27:19 -04:00
|
|
|
|
public ObservableCollection<BaseMedia> SongsList
|
2019-05-19 17:25:42 -04:00
|
|
|
|
{
|
|
|
|
|
get { return _songsList; }
|
2019-05-22 10:30:41 -04:00
|
|
|
|
set { SetProperty(ref _songsList, value); }
|
2019-05-19 17:25:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-24 10:27:19 -04:00
|
|
|
|
public BaseMedia SelectedSong
|
2019-05-19 17:25:42 -04:00
|
|
|
|
{
|
|
|
|
|
get { return _selectedSong; }
|
2019-05-22 10:30:41 -04:00
|
|
|
|
set { SetProperty(ref _selectedSong, value); }
|
2019-05-19 17:25:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-22 10:30:41 -04:00
|
|
|
|
public Command PlayCommand { get; private set; }
|
|
|
|
|
|
2019-05-19 17:25:42 -04:00
|
|
|
|
#endregion Properties
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
|
|
|
|
|
2019-05-19 20:21:54 -04:00
|
|
|
|
SongsList = LibraryService.Instance.GetLibrary();
|
2019-05-19 17:25:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-22 18:59:15 -04:00
|
|
|
|
public void PlayExecute()
|
|
|
|
|
{
|
2019-05-24 10:27:19 -04:00
|
|
|
|
PlayerService.Instance.LoadMedia(_selectedSong);
|
|
|
|
|
PlayerService.Instance.Play();
|
2019-05-22 18:59:15 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-19 17:25:42 -04:00
|
|
|
|
#endregion Methods
|
|
|
|
|
|
2019-05-18 17:25:36 -04:00
|
|
|
|
}
|
|
|
|
|
}
|