public override void WireMessages() { Messenger.Default.Register <NotificationMessage <List <PlaylistItem> > >(this, m => { if (m.Notification.Equals(Constants.Messages.AddToPlaylistMsg)) { _playlistHelper.AddToPlaylist(m.Content); Log.Info("Adding {0} item(s) to the playlist", m.Content.Count); } if (m.Notification.Equals(Constants.Messages.SetPlaylistAsMsg)) { _playlistHelper.ClearPlaylist(); _playlistHelper.AddToPlaylist(m.Content); _navigationService.NavigateTo("/Views/NowPlayingView.xaml"); if (BackgroundAudioPlayer.Instance.PlayerState != PlayState.Playing) { BackgroundAudioPlayer.Instance.Play(); } } if (m.Notification.Equals(Constants.Messages.PlaylistPageLeftMsg)) { if (_playlistChecker.IsEnabled) { _playlistChecker.Stop(); } } }); }
internal static void PlayFolder(String folder, string[] extensions, int startPos) { WifiRemote.LogMessage("Adding all files in " + folder + " to current playlist", WifiRemote.LogType.Debug); if (Directory.Exists(folder)) { PlaylistHelper.ClearPlaylist("video", false); int index = 0; foreach (String f in Directory.GetFiles(folder)) { if (IsValidExtension(f, extensions)) { PlaylistHelper.AddItemToPlaylist("video", f, index, false); index++; } } PlaylistHelper.RefreshPlaylistIfVisible(); PlaylistHelper.StartPlayingPlaylist("video", startPos, true); } else { WifiRemote.LogMessage("Folder " + folder + " doesn't exist", WifiRemote.LogType.Warn); } }
/// <summary> /// Plays all songs from the given folder, starting with item defined by startPos /// </summary> /// <param name="folder">Folder that is played</param> /// <param name="extensions">Valid extensions</param> /// <param name="startPos">Position from where playback is started (playlist index)</param> internal static void PlayAllFilesInFolder(string folder, string[] extensions, int startPos) { WifiRemote.LogMessage("Adding all files in " + folder + " to current playlist", WifiRemote.LogType.Debug); if (Directory.Exists(folder)) { PlaylistHelper.ClearPlaylist("music", false); List <PlayListItem> items = new List <PlayListItem>(); foreach (String f in Directory.GetFiles(folder)) { if (isValidExtension(f, extensions)) { FileInfo fileInfo = new FileInfo(f); items.Add(new PlayListItem(fileInfo.Name, fileInfo.FullName, 0)); } } PlaylistHelper.AddPlaylistItems(PlayListType.PLAYLIST_MUSIC, items, 0); PlaylistHelper.StartPlayingPlaylist("music", startPos, true); } else { WifiRemote.LogMessage("Folder " + folder + " doesn't exist", WifiRemote.LogType.Warn); } }
public override void WireMessages() { Messenger.Default.Register <NotificationMessage <List <PlaylistItem> > >(this, async m => { if (m.Notification.Equals(Constants.Messages.AddToPlaylistMsg)) { await _playlistHelper.AddToPlaylist(m.Content); Log.Info("Adding {0} item(s) to the playlist", m.Content.Count); } if (m.Notification.Equals(Constants.Messages.SetPlaylistAsMsg)) { BackgroundAudioPlayer.Instance.Stop(); BackgroundAudioPlayer.Instance.Track = null; await _playlistHelper.ClearPlaylist(); await _playlistHelper.AddToPlaylist(m.Content); var isNowPlaying = await PlayPause(); NavigationService.NavigateTo(Constants.Pages.NowPlayingView); if (!isNowPlaying) { BackgroundAudioPlayer.Instance.Play(); } } if (m.Notification.Equals(Constants.Messages.PlaylistPageLeftMsg)) { if (_playlistChecker.IsEnabled) { _playlistChecker.Stop(); } } }); Messenger.Default.Register <NotificationMessage>(this, m => { if (m.Notification.Equals(Constants.Messages.ClearNowPlayingMsg)) { NowPlayingItem = null; } }); Messenger.Default.Register <NowPlayingMessage>(this, m => { }); }
/// <summary> /// Plays all songs from the given artist, starting with item defined by startPos /// </summary> /// <param name="albumArtist">Artist that is played</param> /// <param name="startPos">Position from where playback is started (playlist index)</param> internal static void PlayArtist(string albumArtist, int startPos) { List <Song> songs = new List <Song>(); string sql = String.Format("select * from tracks where strAlbumArtist like '%{0}%'", DatabaseUtility.RemoveInvalidChars(albumArtist)); MusicDatabase.Instance.GetSongsByFilter(sql, out songs, "tracks"); if (songs.Count > 0) { PlaylistHelper.ClearPlaylist("music", false); List <PlayListItem> items = new List <PlayListItem>(); foreach (Song s in songs) { items.Add(PlaylistHelper.ToPlayListItem(s)); } PlaylistHelper.AddPlaylistItems(PlayListType.PLAYLIST_MUSIC, items, 0); PlaylistHelper.StartPlayingPlaylist("music", startPos, true); } }