public IEnumerable <Playlist> GetPlaylists() { _api.Playlist_QueryPlaylists(); var playlists = new List <Playlist>(); while (true) { var url = _api.Playlist_QueryGetNextPlaylist(); if (string.IsNullOrEmpty(url)) { break; } var name = _api.Playlist_GetName(url); var playlist = new Playlist { Name = name, Url = url }; playlists.Add(playlist); } return(playlists); }
private List <MusicBeePlaylist> GetMusicBeePlaylists() { List <MusicBeePlaylist> MbPlaylists = new List <MusicBeePlaylist>(); MbApiInterface.Playlist_QueryPlaylists(); string playlist = MbApiInterface.Playlist_QueryGetNextPlaylist(); while (playlist != null) { string playlistName = MbApiInterface.Playlist_GetName(playlist); MusicBeePlaylist MbPlaylist = new MusicBeePlaylist(); MbPlaylist.mbName = playlist; MbPlaylist.Name = playlistName; // get playlist tracks string[] playlistFiles = null; if (MbApiInterface.Playlist_QueryFiles(playlist)) { bool success = MbApiInterface.Playlist_QueryFilesEx(playlist, ref playlistFiles); if (!success) { throw new Exception("Couldn't get playlist files"); } } else { playlistFiles = new string[0]; } foreach (string file in playlistFiles) { string title = MbApiInterface.Library_GetFileTag(file, Plugin.MetaDataType.TrackTitle); string artist = MbApiInterface.Library_GetFileTag(file, Plugin.MetaDataType.Artist); string album = MbApiInterface.Library_GetFileTag(file, Plugin.MetaDataType.Album); var song = new MusicBeeSong() { Album = album, Artist = artist, Title = title, Filename = file, }; MbPlaylist.Songs.Add(song); } MbPlaylists.Add(MbPlaylist); // Query the next mbPlaylist to start again playlist = MbApiInterface.Playlist_QueryGetNextPlaylist(); } MbPlaylists = MbPlaylists.OrderBy(p => p.Name).ToList(); return(MbPlaylists); }