using System.Collections.ObjectModel; using Aurora.Models.Media; using Aurora.Services; using Aurora.Services.PlayerService; using Xamarin.Forms; namespace Aurora.Design.Views.Songs { public class SongsViewModel : BaseViewModel { #region Fields private ObservableCollection _songsList; private BaseMedia _selectedSong; #endregion Fields #region Constructor public SongsViewModel() { _songsList = new ObservableCollection(); PlayCommand = new Command(PlayExecute); Initialize(); } #endregion Constructor #region Properties public ObservableCollection SongsList { get { return _songsList; } set { SetProperty(ref _songsList, value); } } public BaseMedia SelectedSong { get { return _selectedSong; } set { SetProperty(ref _selectedSong, value); } } public Command PlayCommand { get; private set; } #endregion Properties #region Methods public void Initialize() { SongsList = LibraryService.Instance.GetLibrary(); } public void PlayExecute() { PlayerService.Instance.LoadMedia(_selectedSong); PlayerService.Instance.Play(); } #endregion Methods } }