Ejemplo n.º 1
0
        public ImageResponse GetAlbumArt()
        {
            var      musicInfoReader = new MusicInfoReader();
            AlbumArt art             = null;

            if (Player.Current.Playlist.CurrentSong != null)
            {
                art = musicInfoReader.GetAlbumArtForFile(Player.Current.Playlist.CurrentSong.FullPath);
            }

            byte[] data        = null;
            string contentType = "";

            if (art == null)
            {
                data        = BLANKGIF;
                contentType = "image/gif";
            }
            else
            {
                data        = art.RawData;
                contentType = art.ContentType;
            }

            return(new ImageResponse(data, contentType));
        }
Ejemplo n.º 2
0
        public void MusicWithoutMetaDataShouldDefaultToFilename()
        {
            var testFile = @"..\..\..\TestFiles\NoMetadata\NoMetadata.mp3";

            var musicInfoReader = new MusicInfoReader();
            var info            = musicInfoReader.GetInfoForFile(testFile);

            Assert.AreEqual("NoMetadata", info.Title, "When the metadata is missing, the title must be the name of the file.");
        }
Ejemplo n.º 3
0
        public void GetMusicInfoForDirectoryWithoutMusic()
        {
            var testDirectory = ".";

            var musicInfoReader = new MusicInfoReader();

            List <MusicInfo> result = musicInfoReader.CrawlDirectory(testDirectory);

            Assert.IsNotNull(result, "The result must not be null.");
            Assert.AreEqual(0, result.Count, "There must not be any results.");
        }
Ejemplo n.º 4
0
        public void GetMusicInfoForDirectoryWithSubdirectories()
        {
            var testDirectory = @"..\..\..\TestFiles";
            var title         = "four";

            var musicInfoReader = new MusicInfoReader();

            List <MusicInfo> result = musicInfoReader.CrawlDirectory(testDirectory);

            Assert.Greater(result.Count, 0, "There must be more than one item in the result.");

            var fourMp3 = result.FirstOrDefault(X => X.FullPath.IndexOf("four.mp3") > -1);

            Assert.IsNotNull(fourMp3, "There must be an entry for the mp3 file.");
            Assert.AreEqual(title, fourMp3.Title, "The title must be correct.");
        }
Ejemplo n.º 5
0
        public void AddDirectoryToLibrary(string directoryPath)
        {
            var musicInfoReader = new MusicInfoReader();

            if (!Directory.Exists(directoryPath))
            {
                Log.Debug("Couldn't add directory to library: " + directoryPath);
                return;
            }
            else
            {
                Log.Debug("Adding directory to library :" + directoryPath);
            }

            List <MusicInfo> allMusic = musicInfoReader.CrawlDirectory(directoryPath);

            this.AddMusicToLibrary(allMusic.ToArray());
        }
Ejemplo n.º 6
0
        public void ReadTestMP3()
        {
            var testFilePath = @"..\..\..\TestFiles\one.mp3";
            var artist       = "awl";
            var title        = "one";
            var album        = "TestAlbum";
            var trackNumber  = 1;

            var musicInfoReader = new MusicInfoReader();

            MusicInfo result = musicInfoReader.GetInfoForFile(testFilePath);

            Assert.AreEqual(title, result.Title, "The title must be correct.");
            Assert.AreEqual(artist, result.Artist, "The artist must be correct.");
            Assert.AreEqual(album, result.Album, "It must be for the correct album.");
            Assert.AreEqual(testFilePath, result.FullPath, "The full path must be correct.");
            Assert.AreEqual(trackNumber, result.TrackNumber, "The track number must be correct.");
        }