public override void OnCreate() { base.OnCreate(); _queue = new ObservableCollection <Song>(); _pos = 0; _audioManager = (AudioManager)GetSystemService(AudioService); _random = new Random(); _comparer = new SongComparer(); InitializePlayer(); }
public void An_empty_song_isnt_like_a_usual_song() { var emptySong = new Song(); var comparer = new SongComparer(emptySong); var result = comparer.IsLike(new Song() { Title = "TestTitle", Interpret = "Someone" }); Assert.IsFalse(result); }
public void Searching_for_multiple_conditions_matches_a_valid_song() { var searchFor = new Song() { Jahr = 1000, Interpret = "ABC" }; var comparer = new SongComparer(searchFor); var shouldBeTrue = comparer.IsLike(new Song() { Jahr = 1000, Interpret = "XABCDEF" }); Assert.IsTrue(shouldBeTrue); }
public void Searching_for_an_incomplete_Songtitle_matches_the_compete_song() { var searchFor = new Song() { Title = "stT" }; var comparer = new SongComparer(searchFor); var result = comparer.IsLike(new Song() { Title = "TestTitle" }); Assert.IsTrue(result); }
public void Searching_for_a_string_like_the_title_matches_if_both_are_the_same() { var search = new Song() { Title = "TestTitle" }; var comparer = new SongComparer(search); var result = comparer.IsLike(new Song() { Title = "TestTitle" }); Assert.IsTrue(result); }
public void Searching_for_a_only_in_part_matching_song_fails() { var searchFor = new Song() { Jahr = 1000, Interpret = "ABC" }; var comparer = new SongComparer(searchFor); var shouldbeFalse = comparer.IsLike(new Song() { Jahr = 9999, Interpret = "XABCDEF" }); Assert.IsFalse(shouldbeFalse); }
public void Searching_for_a_integer_value_matches_on_the_same_value() { var searchFor = new Song() { Jahr = 1980 }; var comparer = new SongComparer(searchFor); var shouldBeTrue = comparer.IsLike(new Song() { Jahr = 1980 }); var shouldBeFalse = comparer.IsLike(new Song() { Jahr = 1234 }); Assert.IsTrue(shouldBeTrue); Assert.IsFalse(shouldBeFalse); }
public MusicManagerIOS() { _queue = new ObservableCollection <Song>(); _pos = 0; _comparer = new SongComparer(); _random = new Random(); InitializePlayer(); var commandCenter = MPRemoteCommandCenter.Shared; commandCenter.PreviousTrackCommand.Enabled = true; commandCenter.PreviousTrackCommand.AddTarget(PrevCommand); commandCenter.NextTrackCommand.Enabled = true; commandCenter.NextTrackCommand.AddTarget(NextCommand); commandCenter.TogglePlayPauseCommand.Enabled = true; commandCenter.TogglePlayPauseCommand.AddTarget(ToggleCommand); commandCenter.PlayCommand.Enabled = true; commandCenter.PlayCommand.AddTarget(PlayCommand); commandCenter.PauseCommand.Enabled = true; commandCenter.PauseCommand.AddTarget(PauseCommand); }
public PlaylistViewModel(PlaylistItem playlistItem) { Instance = this; _comparer = new SongComparer(); _playlist = playlistItem.Playlist; Id = (ulong)_playlist?.Id; Title = playlistItem.Playlist.Title; if (_playlist.Songs == null || _playlist.Songs.Count == 0) { Task.Run(async() => { SongsLoading = true; OnPropertyChanged(nameof(SongsLoading)); if (playlistItem.Playlist.Title == "All Songs" && !playlistItem.Playlist.IsDynamic) { Songs = await DependencyService.Get <IPlaylistManager>().GetAllSongs(); } else { Songs = await DependencyService.Get <IPlaylistManager>().GetPlaylistSongs(playlistItem.Playlist.Id); } SongsLoading = false; OnPropertyChanged(nameof(SongsLoading)); }); } else { Songs = _playlist.Songs; } PlayCommand = new Command((item) => { DependencyService.Get <IMusicManager>().StartQueue(new ObservableCollection <Song>(Songs), Songs.IndexOf(item as Song)); }); }
public PlaylistViewModel(PlaylistItem playlistItem) { Instance = this; _comparer = new SongComparer(); _playlist = playlistItem.Playlist; Id = _playlist.Id; Title = playlistItem.Playlist.Title; Task.Run(async() => { SongsLoading = true; OnPropertyChanged(nameof(SongsLoading)); Album = await DependencyService.Get <IPlaylistManager>().GetSongsByAlbum(); JukeBoxPlaylist = await DependencyService.Get <IPlaylistManager>().GetPlaylists(); Songs = await DependencyService.Get <IPlaylistManager>().GetAllSongs(); await DependencyService.Get <IMusicManager>().SetQueue(Songs); SongsLoading = false; OnPropertyChanged(nameof(SongsLoading)); //if (playlistItem.Playlist !=null && _playlist.Id > 0) //{ // Songs = await DependencyService.Get<IPlaylistManager>().GetPlaylistSongs(playlistItem.Playlist.Id); // await DependencyService.Get<IMusicManager>().SetQueue(Songs); //} SongsLoading = false; OnPropertyChanged(nameof(SongsLoading)); }); PlaylistSongCommand = new Command((item) => { var jukeBoxPlaylist = item as JukeBoxPlaylist; if (jukeBoxPlaylist != null) { var playlistViewModel = MainViewModel.GetInstance().PlaylistViewModel; playlistViewModel.PlaylistSongs = jukeBoxPlaylist.PlaylistSongs; (App.Current.MainPage as MasterDetailPage).Detail.Navigation.PushAsync(new PlaylistsSongPage(jukeBoxPlaylist)); // await Application.Current.MainPage.Navigation.PushAsync(new SonglistPage(albumItem)); } }); AddSong = new Command(() => { Task.Run(async() => { //DependencyService.Get<IPlaylistManager>().AddToPlaylist( // Playlist, // MusicStateViewModel.Instance.SelectedSong); // playlist.Songs = await DependencyService.Get<IPlaylistManager>().GetPlaylistSongs( // playlist.Id); // await (App.Current.MainPage as MasterDetailPage).Detail.Navigation.PopPopupAsync(true); }); }); PlayCommand = new Command((item) => { var songItem = item as Song; var song = Songs.Where(x => x.Id == songItem.Id).FirstOrDefault(); if (song == null) { Songs.Add(songItem); } var index = Songs.IndexOf(song); this.MusicState.QueuePos = index; DependencyService.Get <IMusicManager>().StartQueue(new ObservableCollection <Song>(Songs), index); }); AlbumQueueCommand = new Command((item) => { if (this.Songs != null) { DependencyService.Get <IMusicManager>().StartQueue(new ObservableCollection <Song>(Songs), 0); } }); AlbumSongCommand = new Command((item) => { var albumItem = item as Albumlist; if (albumItem != null) { var playlistViewModel = MainViewModel.GetInstance().PlaylistViewModel; playlistViewModel.AlbumSongs = albumItem.AlbumsSongs; ShowArtwork = false; (App.Current.MainPage as MasterDetailPage).Detail.Navigation.PushAsync(new SonglistPage(albumItem)); // await Application.Current.MainPage.Navigation.PushAsync(new SonglistPage(albumItem)); } }); ShuffleCommand = new Command(() => DependencyService.Get <IMusicManager>().Shuffle()); if (Songs != null) { HasSongs = true; } else { HasSongs = false; } }