Ejemplo n.º 1
0
        public List <RPMusicAlbum> GetAllAlbums()
        {
            if (!Settings.Default.EnableMusicLibrary)
            {
                return(new List <RPMusicAlbum>());
            }

            WindowsMediaPlayer   WMPlayer = new WindowsMediaPlayer();
            List <RPMusicAlbum>  output   = new List <RPMusicAlbum>();
            IWMPStringCollection scAlbums = WMPlayer.mediaCollection.getAttributeStringCollection("AlbumID", "Audio");

            for (int i = 0; i < scAlbums.count; i++)
            {
                if (string.IsNullOrEmpty(scAlbums.Item(i)))
                {
                    continue;                                         // avoid null strings
                }
                RPMusicAlbum album = new RPMusicAlbum();
                album.ID = scAlbums.Item(i);

                // Find a song in this album
                IWMPPlaylist pl = WMPlayer.mediaCollection.getByAttribute("AlbumID", album.ID);
                if (pl.count < 1)
                {
                    continue;                    // don't add the album; no matching media items  (must be an error, shouldn't happen)
                }
                IWMPMedia song = pl.get_Item(0); // just use the first song to get the additional album info

                // ALBUM ARTIST: Try to use the song property's "album artist", if this doesn't work, use the first song's author
                album.ArtistID = song.getItemInfo("WM/AlbumArtist");
                if (string.IsNullOrEmpty(album.ArtistID))
                {
                    album.ArtistID = song.getItemInfo("Author");
                }

                album.Title   = song.getItemInfo("WM/AlbumTitle");
                album.GenreID = song.getItemInfo("Genre");

                output.Add(album);
            }

            WMPlayer.close();

            // Sort output A-Z
            CommonEPG.Comparers.RPMusicAlbumNameComparer myComparer = new CommonEPG.Comparers.RPMusicAlbumNameComparer();
            output.Sort(myComparer);

            return(output);
        }
Ejemplo n.º 2
0
        public List<RPMusicAlbum> GetAllAlbums()
        {
            MusicHelper helper = new MusicHelper();
            bool failed = false;
            string txtError = "";
            List<RPMusicAlbum> output = helper.RetrieveAllAlbums(ref failed, ref txtError);
            if (failed)
                Functions.WriteLineToLogFile("Failed to get albums from music library: " + txtError);
            else
            {
                // Sort output A-Z
                CommonEPG.Comparers.RPMusicAlbumNameComparer myComparer = new CommonEPG.Comparers.RPMusicAlbumNameComparer();
                output.Sort(myComparer);
            }

            return output;
        }
Ejemplo n.º 3
0
        public List <RPMusicAlbum> GetAllAlbums()
        {
            MusicHelper         helper   = new MusicHelper();
            bool                failed   = false;
            string              txtError = "";
            List <RPMusicAlbum> output   = helper.RetrieveAllAlbums(ref failed, ref txtError);

            if (failed)
            {
                Functions.WriteLineToLogFile("Failed to get albums from music library: " + txtError);
            }
            else
            {
                // Sort output A-Z
                CommonEPG.Comparers.RPMusicAlbumNameComparer myComparer = new CommonEPG.Comparers.RPMusicAlbumNameComparer();
                output.Sort(myComparer);
            }

            return(output);
        }
Ejemplo n.º 4
0
        public List<RPMusicAlbum> GetAllAlbums()
        {
            if (!Settings.Default.EnableMusicLibrary) return new List<RPMusicAlbum>();

            WindowsMediaPlayer WMPlayer = new WindowsMediaPlayer();
            List<RPMusicAlbum> output = new List<RPMusicAlbum>();
            IWMPStringCollection scAlbums = WMPlayer.mediaCollection.getAttributeStringCollection("AlbumID", "Audio");

            for (int i = 0; i < scAlbums.count; i++)
            {
                if (string.IsNullOrEmpty(scAlbums.Item(i))) continue; // avoid null strings

                RPMusicAlbum album = new RPMusicAlbum();
                album.ID = scAlbums.Item(i);

                // Find a song in this album
                IWMPPlaylist pl = WMPlayer.mediaCollection.getByAttribute("AlbumID", album.ID);
                if (pl.count < 1) continue; // don't add the album; no matching media items  (must be an error, shouldn't happen)

                IWMPMedia song = pl.get_Item(0); // just use the first song to get the additional album info

                // ALBUM ARTIST: Try to use the song property's "album artist", if this doesn't work, use the first song's author
                album.ArtistID = song.getItemInfo("WM/AlbumArtist");
                if (string.IsNullOrEmpty(album.ArtistID))
                    album.ArtistID = song.getItemInfo("Author");

                album.Title = song.getItemInfo("WM/AlbumTitle");
                album.GenreID = song.getItemInfo("Genre");

                output.Add(album);
            }

            WMPlayer.close();

            // Sort output A-Z
            CommonEPG.Comparers.RPMusicAlbumNameComparer myComparer = new CommonEPG.Comparers.RPMusicAlbumNameComparer();
            output.Sort(myComparer);

            return output;
        }