/// <summary> /// Add a list of songs to the playlist /// </summary> /// <param name="playlist"></param> /// <param name="songs"></param> public void AddSongs(IEnumerable <Song> songs) { List <SongPlaylistItem> songPlaylistItems = new(); // For each song create a PlayListItem and add to the PlayList foreach (Song song in songs) { song.Artist = Artists.GetArtistById(ArtistAlbums.GetArtistAlbumById(song.ArtistAlbumId).ArtistId); SongPlaylistItem itemToAdd = new() { Artist = song.Artist, PlaylistId = Id, Song = song, SongId = song.Id, Index = PlaylistItems.Count }; songPlaylistItems.Add(itemToAdd); PlaylistItems.Add(itemToAdd); } // No need to wait for this DbAccess.InsertAllAsync(songPlaylistItems); }
/// <summary> /// Adds a song which is performed by a list of singers in karaokeBarMode /// </summary> /// <param name="song">song that should be enqueued</param> /// <param name="singers">singers performing the song</param> public void EnqueueSong(Song song, IEnumerable <Singer> singers) { PlaylistItem playlistItem = new PlaylistItem(song, singers); PlaylistItems.Add(playlistItem); SelectLastPlaylistItemInGrid(); }
/// <summary> /// Adds a number of songs without singers within the simple mode /// </summary> /// <param name="songs">songs that should be enqueued</param> public void EnqueueSongs(List <Song> songs) { foreach (Song song in songs) { PlaylistItem playlistItem = new PlaylistItem(song); PlaylistItems.Add(playlistItem); } SelectLastPlaylistItemInGrid(); }
/// <summary> /// Adds a single song in Simple (without singer) or KaraokeBar (with singer) mode /// </summary> /// <param name="song">song that should be enqueued</param> /// <param name="startPlayingIfEmptyPlaylist"></param> /// <param name="singer">singer or null</param> public void EnqueueSong(Song song, bool startPlayingIfEmptyPlaylist = false, Singer singer = null) { PlaylistItem playlistItem = new PlaylistItem(song, singer); PlaylistItems.Add(playlistItem); if (PlaylistItems.Count == 1 && startPlayingIfEmptyPlaylist) { PlayItem(playlistItem); } }
private async Task LoadPlaylistInfoInternal(string playlistid) { PlaylistItems.Clear(); string pagination = null; string firstpagination = null; // Loop through 4 times to load this completely at least // due to YouTube's 50 result restriction // Max playlist restriction = 200 video anyway for (int i = 0; i < 4; i++) { IList <Google.Apis.YouTube.v3.Data.PlaylistItem> collection = null; // Load playlist var videoInfoRequest = YoutubeService.service.PlaylistItems.List("contentDetails,id,status,snippet"); videoInfoRequest.PlaylistId = playlistid; videoInfoRequest.MaxResults = 50; if (pagination != null) { videoInfoRequest.PageToken = pagination; } try { var videoResultResponse = await videoInfoRequest.ExecuteAsync(); // Set new pagination pagination = videoResultResponse.NextPageToken; if (firstpagination == null) { firstpagination = pagination; // no choice, we might load the first at the end again.. there's no pagination information for the first page } else if (firstpagination == pagination) { break; } collection = videoResultResponse.Items; } catch { } // Add it to new collection if (collection != null) { foreach (Google.Apis.YouTube.v3.Data.PlaylistItem item in collection) { // item.Snippet.ur PlaylistItems.Add(item); } } } // Update playlist item count PlaylistItemsCount = _PlaylistItems.Count; }
/// <summary> /// Categorise the specified selected objects /// </summary> /// <param name="selectedObjects"></param> public GroupedSelection(IEnumerable <object> selectedObjects) { // Save the unprocessed objects. SelectedObjects = selectedObjects; // Group the objects into sets of Song, PlaylistItem, IPlaylist, Artist, ArtistAlbum, Album and Genre (string) items foreach (object selectedObject in selectedObjects) { if (selectedObject is Song song) { Songs.Add(song); } else if (selectedObject is PlaylistItem playlistItem) { PlaylistItems.Add(playlistItem); } else if (selectedObject is Playlist playlist) { Playlists.Add(playlist); } else if (selectedObject is Artist artist) { Artists.Add(artist); } else if (selectedObject is ArtistAlbum artistAlbum) { ArtistAlbums.Add(artistAlbum); } else if (selectedObject is Album album) { Albums.Add(album); } else if (selectedObject is string str) { Genres.Add(str); } } // Determine if there is a parent playlist if (PlaylistItems.Count > 0) { ParentPlaylist = DBTest.Playlists.GetParentPlaylist(PlaylistItems[0]); } }
public MainViewModel() { instance = this; this.Login = new LoginViewModel(); this.LibraryModel = new LibraryViewModel(0); this.LibraryPromoModel = new LibraryPromoViewModel(); this.LibraryDetailModel = new LibraryDetailViewModel(); this.LibraryTypeModel = new LibraryTypeViewModel(1); this.PlaylistItems = new ObservableCollection <PlaylistItem>(); PlaylistItems.Add(new PlaylistItem( new Playlist { Title = "Home", IsDynamic = false })); this.PlaylistViewModel = new PlaylistViewModel(PlaylistItems[0]); // this.Library = this.LibraryModel.Library; // this.LibraryDetail = new LibraryDetailViewModel.LibraryDetail(); this.LoadMenu(); }
/// <summary> /// Add a list of albums to the playlist /// </summary> /// <param name="albums"></param> public void AddAlbums(IEnumerable <Album> albums) { // For each song create an AlbumPlayListItem and add to the PlayList List <AlbumPlaylistItem> albumPlaylistItems = new(); foreach (Album album in albums) { AlbumPlaylistItem itemToAdd = new() { Album = album, PlaylistId = Id, AlbumId = album.Id, Index = PlaylistItems.Count }; PlaylistItems.Add(itemToAdd); albumPlaylistItems.Add(itemToAdd); } // No need to wait for this to complete DbAccess.InsertAllAsync(albumPlaylistItems); }