Exemple #1
0
        /// <inheritdoc/>
        public IEnumerable <RadioStation> GetRadioStations()
        {
            var success = _api.Library_QueryFilesEx("domain=Radio", out var radioStations);
            List <RadioStation> stations;

            if (success)
            {
                stations = radioStations.Select(s => new RadioStation
                {
                    Url  = s,
                    Name = _api.Library_GetFileTag(s, TrackTitle),
                }).ToList();
            }
            else
            {
                stations = new List <RadioStation>();
            }

            return(stations);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 private int GetTrackNumber(string currentTrack)
 {
     int.TryParse(_api.Library_GetFileTag(currentTrack, TrackNo), out var trackNumber);
     return(trackNumber);
 }