Esempio n. 1
0
        /// <summary>
        /// The current music track changes
        /// </summary>
        /// <param name="musicFile"></param>
        private async Task OnCurrentMusicTrackChanged(MusicFile musicFile)
        {
            if (musicFile != null)
            {
                // Write to log
                Logger.Log("Music", "Playing: {0}", musicFile.Name);

                // Change the console title
                Console.Title = musicFile.Name;

                // Change the discord status
                await m_Client.SetGameAsync(musicFile.Name, null, ActivityType.Listening).ConfigureAwait(false);

                // Posts a message to the notification channel
                await UpdateTrackInNotificationChannel(musicFile).ConfigureAwait(false);
            }
            else
            {
                // Change the console title
                Console.Title = "DiscordMusicPlayer";

                // Change the discord status
                await m_Client.SetGameAsync(null).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
        private bool AddMusic(string musicName, MusicFile musicFile, bool forceReplace)
        {
            var musicNameLower = musicName.ToLowerInvariant();

            if (MusicFiles.ContainsKey(musicNameLower))
            {
                if (forceReplace && MusicFiles[musicNameLower].IsStandard)
                {
                    MusicFiles.Remove(musicNameLower);
                }
                else
                {
                    return(true);
                }
            }
            MusicFiles.Add(musicNameLower, new MusicClip(musicFile));

            // TODO: Loading every music increases uned memory size duh
            //if (!musicFile.ForceLoad())
            //{
            //    Logger.Log(Logger.LogTypes.Warning, $"MusicTrack.cs: File at \"{musicFile.LocalPath}\" is not a valid music file!");
            //    return false;
            //}
            return(true);
        }
Esempio n. 3
0
        public async Task <bool> PostPlaylist()
        {
            var rawData = await HttpContext.GetRequestFormDataAsync();

            if (rawData.Get("name") != null && rawData.Get("songs") != null)
            {
                Playlist playlist = new Playlist();
                playlist.Name = rawData.Get("name");
                List <MusicFile> songs = new List <MusicFile>();
                var ids = rawData.Get("songs").Split(',');
                foreach (string id in ids)
                {
                    int  song_id;
                    bool parse = int.TryParse(id, out song_id);
                    if (parse)
                    {
                        var song = new MusicFile();
                        song.Id = song_id;
                        songs.Add(song);
                    }
                    else
                    {
                        throw new Exception("Non integer song ID found in urlencoded data.");
                    }
                }
                playlist.Songs = songs;
                return(await _pdb.Add(playlist));
            }

            return(false);
        }
        public AudioPlayerViewModel(INavigation navigation = null) : base(navigation)
        {
            _audioPlayerManager       = DependencyService.Get <IAudioPlayerManager>();
            _musicDictionary          = DependencyService.Get <IMusicDictionary>();
            _devicePermissionServices = DependencyService.Get <IDevicePermissionServices>();
            SetPageImageSize();
            MusicFiles         = new List <MusicFile>();
            AllMusicFiles      = new List <MusicFile>();
            PlaylistMusicFiles = new List <MusicFile>();
            CurrentMusicFile   = new MusicFile();
            PlayButton         = ImageResizer.ResizeImage(TextResources.icon_media_play, ButtonImageSize);
            PauseButton        = ImageResizer.ResizeImage(TextResources.icon_media_pause, ButtonImageSize);
            StopButton         = ImageResizer.ResizeImage(TextResources.icon_media_stop, ButtonImageSize);
            NextButton         = ImageResizer.ResizeImage(TextResources.icon_media_next, ButtonImageSize);
            PreviousButton     = ImageResizer.ResizeImage(TextResources.icon_media_previous, ButtonImageSize);
            ForwardButton      = ImageResizer.ResizeImage(TextResources.icon_media_forward, ButtonImageSize);
            BackwardButton     = ImageResizer.ResizeImage(TextResources.icon_media_backward, ButtonImageSize);
            PlayPauseButton    = PlayButton;
            NowPlayingButton   = PlayButton;

            ChecklistImage    = ChecklistDefaultImage;
            SortImage         = SortDefaultImage;
            PlaylistTextStyle = PlaylistTextStyleDefault;
            PlaylistSortBy    = PlaylistSortList.Title;

            IsPlaying           = false;
            IsPause             = false;
            IsMediaExists       = false;
            CurrentSongIndex    = 0;
            IsLoopStarted       = false;
            IsPermissionGranted = false;
        }
Esempio n. 5
0
        // Update ID3 tags on the downloaded mp3
        private void tagFile(MusicFile file)
        {
            int iRetries = 0;

            _files[0].DownloadedFile.Refresh();
            while ((!_files[0].DownloadedFile.Exists || _files[0].DownloadedFile.Length == 0) && iRetries < 30)
            {
                // Downloaded, but not flushed?  Sleep for a little while.
                iRetries++;
                System.Threading.Thread.Sleep(1000);
                _files[0].DownloadedFile.Refresh();
            }

            if (iRetries == 30)
            {
                // The file was never written.  We really need some proper error handling, but this will have to
                // do for now.
                throw new Exception("File " + _files[0].DownloadedFile.Name + " has a size of zero bytes and cannot be tagged.");
            }
            else
            {
                TagLib.File tagger = TagLib.File.Create(file.DownloadedFile.FullName);
                tagger.Tag.Album        = file.Album;
                tagger.Tag.AlbumArtists = new string[] { file.Artist };
                tagger.Tag.Title        = file.Title;
                tagger.Save();
            }
        }
Esempio n. 6
0
        public async Task ImplicitLoadMetadata()
        {
            var metadata  = new MusicMetadata(TimeSpan.Zero, 0);
            var musicFile = new MusicFile(async fileNme =>
            {
                await Task.Yield();
                return(metadata);
            }, "testfile.mp3");

            Assert.AreEqual("testfile.mp3", musicFile.FileName);
            Assert.IsFalse(musicFile.SharedMusicFiles.Any());
            Assert.IsFalse(musicFile.IsMetadataLoaded);

            Assert.IsNull(musicFile.Metadata);
            await Task.Delay(5);

            Assert.AreEqual(metadata, musicFile.Metadata);
            Assert.AreEqual(metadata, musicFile.GetMetadataAsync().Result);
            Assert.IsTrue(musicFile.IsMetadataLoaded);
            Assert.AreEqual(musicFile, musicFile.Metadata.Parent);

            Assert.IsFalse(musicFile.Metadata.HasChanges);
            musicFile.Metadata.Rating = 33;
            Assert.IsTrue(musicFile.Metadata.HasChanges);
        }
Esempio n. 7
0
        /// <summary>
        /// Posts the current track in the notification channel
        /// </summary>
        /// <param name="musicFile">The current music file</param>
        private async Task UpdateTrackInNotificationChannel(MusicFile musicFile)
        {
            // Skip if there is no notification channel
            if (m_CurrentNotificationChannel == null)
            {
                return;
            }

            // Also skip if the music file is null
            if (musicFile == null)
            {
                return;
            }

            // And also the notification message must be set
            if (string.IsNullOrEmpty(NotificationMessage))
            {
                return;
            }

            // Builds the message
            string message = NotificationMessage;

            message = message.Replace("{{title}}", musicFile.Title, StringComparison.InvariantCulture);
            message = message.Replace("{{artist}}", musicFile.Artists, StringComparison.InvariantCulture);
            message = message.Replace("{{album}}", musicFile.Album, StringComparison.InvariantCulture);

            // Sends the message
            await m_CurrentNotificationChannel.SendMessageAsync(message).ConfigureAwait(false);
        }
Esempio n. 8
0
    private MusicFile CreateMusicFileObjects()
    {
        GameObject musicFileObject = new GameObject("MusicFile");
        MusicFile  newMusicFile    = musicFileObject.AddComponent <MusicFile>();

        return(newMusicFile);
    }
Esempio n. 9
0
        public static string GetArtistName(this MusicFile mf /*, MusicDb db*/)
        {
            var name = mf.Musician;

            switch (mf.Encoding)
            {
            case EncodingType.flac:
                Debug.Assert(mf.IsGenerated == false);
                switch (mf.Style)
                {
                case MusicStyles.WesternClassical:
                    name = mf.GetTagValue <string>("Composer") ?? mf.GetTagValue <string>("Artist") ?? name;
                    break;

                default:
                    name = mf.GetTagValue <string>("Artist") ?? name;
                    break;
                }
                break;

            default:
                if (mf.IsGenerated)
                {
                    name = mf.GetTagValue <string>("Artist");
                }
                else
                {
                    name = mf.GetTagValue <string>("Artist") ?? mf.GetTagValue <string>("AlbumArtists") ?? name;
                    name = name.Split('|', ';', ',', ':')[0].Trim();
                }
                break;
            }
            return(name);
        }
Esempio n. 10
0
        public static void Delete(this MusicDb musicDb, MusicFile mf, DeleteContext context)
        {
            void clearRelatedEntities(MusicFile file)
            {
                musicDb.RemovePlaylistItems(file);
                var tags = file.IdTags.ToArray();

                musicDb.IdTags.RemoveRange(tags);
            }

            clearRelatedEntities(mf);
            var track = mf.Track;

            track?.MusicFiles.Remove(mf);
            if (track?.MusicFiles.All(x => x.IsGenerated) ?? false)
            {
                foreach (var f in track.MusicFiles.ToArray())
                {
                    clearRelatedEntities(f);
                    f.Track = null;
                    track.MusicFiles.Remove(f);
                    musicDb.MusicFiles.Remove(f);
                    log.Information($"{context}: Musicfile [MF-{f.Id}] deleted: {f.File}");
                }
            }
            if (track?.MusicFiles.Count() == 0)
            {
                musicDb.Delete(track, context);
            }
            musicDb.MusicFiles.Remove(mf);
            log.Information($"{context}: Musicfile [MF-{mf.Id}] deleted: {mf.File}");
        }
Esempio n. 11
0
    // validates the "recipe" for the song naming..
    private void tbCommonNaming_TextChanged(object sender, EventArgs e)
    {
        // avoid replicating the code..
        Label   label   = sender.Equals(tbAlbumNaming) ? lbNamingSampleValue : lbNamingSampleRenamedValue;
        TextBox textBox = (TextBox)sender;

        label.Text =
            MusicFile.GetString(textBox.Text,
                                DBLangEngine.GetMessage("msgArtists", "Artist|As in an artist(s) of a music file"),
                                DBLangEngine.GetMessage("msgAlbum", "Album|As in a name of an album of a music file"),
                                1,
                                DBLangEngine.GetMessage("msgTitle", "Title|As in a title of a music file"),
                                DBLangEngine.GetMessage("msgMusicFile", "A01 Song Name|A sample file name without path of a music file name"),
                                1, 2,
                                DBLangEngine.GetMessage("msgMusicFileRenamed", "I named this song my self|The user has renamed the song him self"),
                                DBLangEngine.GetStatMessage("msgError", "Error|A common error that should be defined in another message"), out bool error);

        bool formulaInText = // check that the formula has been parsed properly..
                             label.Text.Contains("#ARTIST") ||
                             label.Text.Contains("#ALBUM") ||
                             // ReSharper disable once StringLiteralTypo
                             label.Text.Contains("#TRACKNO") ||
                             label.Text.Contains("#QUEUE") ||
                             label.Text.Contains("#ALTERNATE_QUEUE") ||
                             label.Text.Contains("#RENAMED");

        error |= formulaInText;


        // indicate invalid naming formula..
        textBox.ForeColor = error || string.IsNullOrWhiteSpace(Text) ? Color.Red : SystemColors.WindowText;


        bOK.Enabled = !error && textBox.Text.Trim() != string.Empty;
    }
Esempio n. 12
0
        public void GetQueue(string path)
        {
            try
            {
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                var filenames = new List <string>();
                GetMusicFiles(path, ref filenames);

                foreach (var file in filenames)
                {
                    var musicFile = new MusicFile
                    {
                        fileName = Path.GetFileName(file),
                        filePath = Path.GetDirectoryName(file),
                        fileGuid = Guid.NewGuid()
                    };

                    if (dal.AddToQueue(musicFile) > 0)
                    {
                        uploadQueue.Add(musicFile);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message);
            }
        }
Esempio n. 13
0
 private static bool IsContained(MusicFile musicFile, string searchText)
 {
     return(MusicTitleHelper.GetTitleText(musicFile.FileName, musicFile.IsMetadataLoaded ? musicFile.Metadata.Artists : null, musicFile.IsMetadataLoaded ? musicFile.Metadata.Title : null)
            .IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
            musicFile.IsMetadataLoaded &&
            (musicFile.Metadata.Artists.Any(y => y.IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase) >= 0)));
 }
 public void Init(MusicFile selectedMusicFile, List <MusicFile> musicFiles)
 {
     SelectedMusicFile = selectedMusicFile;
     _musicFiles       = musicFiles;
     IsPlayBtnVisibile = false;
     IsPauseBtnVisible = true;
 }
Esempio n. 15
0
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect = true;
            dialog.Filter      = "Music file (*.mp3;*.wav)|*.mp3;*.wav;";
            if (!dialog.ShowDialog().Value)
            {
                return;
            }
            foreach (string file in dialog.FileNames)
            {
                string    fileName  = file.Substring(file.LastIndexOf('\\') + 1);
                MusicFile musicFile = new MusicFile()
                {
                    FilePath = file,
                    FileName = fileName
                };
                if (Settings.GetSettings().MusicFiles.Select(m => m.FileName).Contains(fileName))
                {
                    continue;
                }
                Settings.AddMusicFile(musicFile);
            }
        }
Esempio n. 16
0
 public void ApplyChanges(MusicFile musicFile)
 {
     if (ApplyChangesAction != null)
     {
         ApplyChangesAction(musicFile);
     }
 }
Esempio n. 17
0
        private async Task GetFiles(string path, List <MusicFile> musicFiles)
        {
            await Task.Run(async() => {
                var files = Directory.GetFiles(path);
                foreach (var file in files)
                {
                    if (_fileExtensions.ContainsKey(Path.GetExtension(file)) == true)
                    {
                        var tfile = TagLib.File.Create(file);

                        MusicFile musicFile = new MusicFile()
                        {
                            Album       = tfile.Tag.Album,
                            Artist      = tfile.Tag.FirstAlbumArtist,
                            Path        = file,
                            Title       = tfile.Tag.Title,
                            TrackNumber = (int)tfile.Tag.Track,
                            Year        = (int)tfile.Tag.Year,
                            Duration    = tfile.Properties.Duration
                        };
                        musicFiles.Add(musicFile);
                    }
                }
                var directories = Directory.GetDirectories(path);
                foreach (var directory in directories)
                {
                    if (Directory.Exists(directory))
                    {
                        //recurse if directory
                        await GetFiles(directory, musicFiles);
                    }
                }
            });
        }
 public void Add(MusicFile item)
 {
     if (!Files.Contains(item))
     {
         Files.Add(item);
     }
 }
Esempio n. 19
0
        public static async Task <bool> UploadMusic(string path, string name, string singer, string uname)
        {
            MusicFile file = new MusicFile();

            file.name   = name;
            file.singer = singer;
            file.suffix = Path.GetExtension(path);
            file.file   = GetFileByte(path);
            file.uname  = uname;
            //file.file = null;
            TcpConnection con = new TcpConnection();
            await con.Connect(ip, port);

            await con.Send(GetUploadMessage(file));

            object obj = await con.ReceiveOnceAsync();

            con.Close();
            NetMessage message = obj as NetMessage;

            if (message.Message == MessageType.Success)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 20
0
        public void TestIndexer()
        {
            MusicFile track1 = new MusicFile("t1.mp3", "I follow Rivers", "Likki Li", MusicGenre.Dance);
            MusicFile track2 = new MusicFile("t2.mp3", "Since I Left You", "The Avalanches", MusicGenre.Dance);
            MusicFile track3 = new MusicFile("t3.mp3", "Run to the Hills", "Iron Maiden", MusicGenre.Rock);

            Playlist playlist = new Playlist("Cool Tunes");

            playlist.AddTrack(track1);
            playlist.AddTrack(track2);
            playlist.AddTrack(track3);

            // make a List of dance tracks added
            List <MusicFile> danceTracks = new List <MusicFile>();

            danceTracks.Add(track1);
            danceTracks.Add(track2);

            // make a List of dance tracks as determined by indexer
            List <MusicFile> playlistDanceTracks = new List <MusicFile>();

            foreach (MusicFile t in playlist[MusicGenre.Dance])
            {
                playlistDanceTracks.Add(t);
            }

            // both lists should be equal
            CollectionAssert.AreEqual(danceTracks, playlistDanceTracks);
        }
Esempio n. 21
0
 protected override MusicFileTEO CreateMusicFileTeo(MusicFile mf)
 {
     return(new PopularMusicFileTEO(musicOptions)
     {
         MusicFile = mf
     });
 }
Esempio n. 22
0
 protected override MusicFileTEO CreateMusicFileTeo(MusicFile mf)
 {
     return(new WesternClassicalMusicFileTEO(musicOptions)
     {
         MusicFile = mf
     });
 }
Esempio n. 23
0
        public async Task <bool> Add(MusicFile file)
        {
            _db.Open();
            string sql          = @"INSERT INTO music_files (
                            path,
                            album,
                            artist,
                            title,
                            year,
                            track_number
                        )
                        VALUES (
                            @path,
                            @album,
                            @artist,
                            @title,
                            @year,
                            @track_number
                        );";
            var    affectedRows = 0;

            try
            {
                affectedRows = await _db.ExecuteAsync(sql,
                                                      new { path = file.Path, album = file.Album, artist = file.Artist, title = file.Title, year = file.Year, track_number = file.TrackNumber });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            _db.Close();
            return(affectedRows == 1);
        }
Esempio n. 24
0
        public MusicFile Create(string fileName)
        {
            CompactCache();

            WeakReference <MusicFile> weakMusicFile;
            MusicFile musicFile;

            if (musicFilesCache.TryGetValue(fileName, out weakMusicFile))
            {
                if (weakMusicFile.TryGetTarget(out musicFile))
                {
                    return(musicFile);
                }
                else
                {
                    musicFilesCache.TryRemove(fileName, out weakMusicFile);
                }
            }

            Task runningTranscodingTask;

            runningTranscodingTasks.TryGetValue(fileName, out runningTranscodingTask);
            musicFile = new MusicFile(x => LoadMetadata(x, runningTranscodingTask), fileName);

            if (!musicFilesCache.TryAdd(fileName, new WeakReference <MusicFile>(musicFile)))
            {
                throw new InvalidOperationException("Race condition: This should not happen.");
            }
            return(musicFile);
        }
Esempio n. 25
0
        /// <summary>
        /// Accounts for if the user moves the music directory to another location
        /// </summary>
        private bool DoWeHaveAMusicFileWithTheSameHash(
            MusicFile musicFile,
            out MusicFile existingMusicFile)
        {
            existingMusicFile = null;

            try
            {
                if (string.IsNullOrEmpty(musicFile.Hash))
                {
                    return(false);
                }

                string hash     = DirectoryHelper.GetFileHash(musicFile.Path).Result;
                var    existing = MainForm.MusicFileRepo.GetDuplicate(hash, musicFile.Path).Result;

                if (existing != null)
                {
                    existingMusicFile = existing;
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logger.Log(e, "DoWeHaveAMusicFileWithTheSameHash");
            }

            return(false);
        }
Esempio n. 26
0
        public void TotalDurationWithMetadataLoading()
        {
            var manager = new PlaylistManager();

            Assert.AreEqual(TimeSpan.Zero, manager.TotalDuration);
            var firstFile = new MockMusicFile(new MusicMetadata(TimeSpan.FromSeconds(10), 0), "");

            manager.AddAndReplaceItems(new[] { new PlaylistItem(firstFile) });

            var secondMetadata = new MusicMetadata(TimeSpan.FromSeconds(20), 0);
            var secondFile     = new MusicFile(async x =>
            {
                await Task.Delay(10);
                return(secondMetadata);
            }, "");

            manager.AddItems(new[] { new PlaylistItem(secondFile) });
            Assert.IsTrue(manager.IsTotalDurationEstimated);
            Assert.AreEqual(TimeSpan.FromSeconds(20), manager.TotalDuration);
            AssertHelper.PropertyChangedEvent(manager, x => x.TotalDuration, () => secondFile.GetMetadataAsync().GetResult());
            Assert.IsFalse(manager.IsTotalDurationEstimated);
            Assert.AreEqual(TimeSpan.FromSeconds(30), manager.TotalDuration);

            var thirdFile = new MockMusicFile(new MusicMetadata(TimeSpan.FromSeconds(30), 0), "");

            AssertHelper.PropertyChangedEvent(manager, x => x.TotalDuration, () => manager.AddItems(new[] { new PlaylistItem(thirdFile) }));
            Assert.AreEqual(TimeSpan.FromSeconds(60), manager.TotalDuration);
        }
Esempio n. 27
0
 public static void Play(MusicFile music)
 {
     if (music.introClip && music.loopClip)
     {
         Instance.PlayLoop(music.introClip, music.loopClip);
     }
 }
Esempio n. 28
0
        /// <summary>
        /// returns a list of directories found in all sources that match either the artist, or the work
        /// Note that a directory will match if the name matches ignoring accents or case
        /// </summary>
        /// <param name="musicStyle"></param>
        /// <param name="musicOptions"></param>
        /// <param name="artistName"></param>
        /// <param name="workName"></param>
        /// <returns></returns>

        /// <summary>
        /// Reads all the tags in the audio file and adds them to the database
        /// (Not all the tags are used)
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static async Task UpdateTagsAsync(this MusicDb db, MusicFile mf /*, bool force = false*/)
        {
            if (/*force == true*/
                /*||*/ mf.ParsingStage == MusicFileParsingStage.Unknown ||
                mf.ParsingStage == MusicFileParsingStage.Initial ||
                (mf.FileLastWriteTimeUtc != new IO.FileInfo(mf.File).LastWriteTimeUtc))
            {
                // for western classical the important tags are:
                //      ArtistName, WorkName, Year, Composition, Orchestra, Conductor, Performers, TrackNumber, Title
                //      what about cover art?? can I assume that there will always be an image file on disk somewhere??
                var oldTags = mf.IdTags.ToArray();
                mf.IdTags.Clear();
                db.IdTags.RemoveRange(oldTags);
                switch (mf.Encoding)
                {
                case EncodingType.flac:
                    db.UpdateFlacTagsAsync(mf);
                    break;

                default:
                    await db.UpdateMp3TagsAsync(mf);

                    break;
                }
                mf.ParsingStage = MusicFileParsingStage.IdTagsComplete;
            }
        }
Esempio n. 29
0
        private async Task HandleUploadCheck(MusicFile musicFile)
        {
            var alreadyUploaded = Requests.IsSongUploaded(musicFile.Path,
                                                          MainForm.Settings.AuthenticationCookie,
                                                          out string entityId,
                                                          MainForm.MusicDataFetcher);

            if (alreadyUploaded != Requests.UploadCheckResult.NotPresent)
            {
                if (ThreadIsAborting())
                {
                    return;
                }

                await HandleFileAlreadyUploaded(
                    musicFile,
                    entityId);
            }
            else
            {
                if (ThreadIsAborting())
                {
                    return;
                }

                await HandleFileNeedsUploading(musicFile);
            }
        }
Esempio n. 30
0
        public static string GetWorkName(this MusicFile mf /*, MusicDb db*/)
        {
            var name = mf.OpusName;

            if (!(mf.OpusType == OpusType.Singles))
            {
                switch (mf.Encoding)
                {
                case EncodingType.flac:
                default:
                    //Debug.Assert(mf.IsGenerated == false);
                    switch (mf.Style)
                    {
                    case MusicStyles.WesternClassical:
                        name = mf.GetTagValue <string>("Composition") ?? mf.GetTagValue <string>("Album") ?? name;
                        break;

                    default:
                        name = mf.GetTagValue <string>("Album") ?? name;
                        break;
                    }
                    break;
                }
            }
            return(name);
        }
Esempio n. 31
0
        public void TestIndexer()
        {
            MusicFile m1 = new MusicFile("t1.mp3", "Rivers", "JT", MusicGenre.Dance);
            MusicFile m2 = new MusicFile("t2.mp3", "Mountains", "Britney");
            MusicFile m3 = new MusicFile("t3.mp3", "Hills", "Toni", MusicGenre.Dance);
            // full playlist with all genres
            PlaylistCollection pl = new PlaylistCollection("Songs");

            pl.AddTrack(m1);
            pl.AddTrack(m2);
            pl.AddTrack(m3);
            // Manually adding dance music
            List <MusicFile> danceList = new List <MusicFile>();

            danceList.Add(m1);
            danceList.Add(m3);
            // Indexer adding based on genre
            List <MusicFile> playlistDanceList = new List <MusicFile>();

            foreach (MusicFile m in pl[MusicGenre.Dance])
            {
                playlistDanceList.Add(m);
            }
            // checks both lists are equal
            CollectionAssert.AreEqual(danceList, playlistDanceList);
        }
Esempio n. 32
0
        public void Load_Id3V1_Mp3_File()
        {
            DirectoryInfo dirInfo = TestHelpers.GetTestDirectoryInfo();
            string path = dirInfo.FullName + @"\TagMp3SaitoTestProject\Mp3_To_Test\04 Ex-amor.mp3";

            var mus = new MusicFile(path, TestHelpers.GetMp3FieldsSelecionados());
            Assert.AreEqual(path, mus.FullPath);
        }
Esempio n. 33
0
        private void MakeWMAPreferred(MusicFile fileToCopy)
        {
            var ext = fileToCopy.FileExtention.ToUpper();

            if (ext != WMA_EXT) return;

            var mp3File = Path.Combine(settings.OutputFolder, fileToCopy.TitleAndArtist + MP3_EXT);
            if (File.Exists(mp3File))
            {
                File.Delete(mp3File);
            }
        }
Esempio n. 34
0
        protected override void RefreshLocal()
        {
            LocalFiles.Clear();

            foreach (string file in Directory.EnumerateFiles(WorkingDirectory))
            {
                string fullpath = Path.GetFullPath(file);
                try
                {
                    var musicFile = new MusicFile(fullpath);
                    LocalFiles.Add(fullpath, musicFile);
                }
                catch (UnsupportedFormatException)
                {
                }
            }
        }
 public bool Contains(MusicFile item)
 {
     return Files.Contains(item);
 }
Esempio n. 36
0
 public void CopyMusicFile(MusicFile fileToCopy)
 {
     var outputFile = Path.Combine(settings.OutputFolder, fileToCopy.TitleAndArtist + fileToCopy.FileExtention);
     MakeWMAPreferred(fileToCopy);
     File.Copy(fileToCopy.OriginalFile, outputFile, settings.Overwrite);
 }
        void AddToCollection(string file, bool fromDirectory)
        {
            tagEditor.LoadFileDetails(file);
            var fileName = Path.GetFileNameWithoutExtension(file);

            var musicFile = new MusicFile
                {
                    OriginalFile = file,
                    Artist = tagEditor.Artist,
                    Title = tagEditor.Title,
                    FromDirectory = fromDirectory,
                    FileName = fileName,
                    FileExtention = Path.GetExtension(file),
                    DisplayName = GetDisplayName(fileName)
                };

            Add(musicFile);
        }
Esempio n. 38
0
 public void Update_Some_Information()
 {
     DirectoryInfo dirInfo = TestHelpers.GetTestDirectoryInfo();
     string path = dirInfo.FullName + @"\TagMp3SaitoTestProject\Mp3_To_Test\04 Ex-amor.mp3";
     var mus = new MusicFile(path, TestHelpers.GetMp3FieldsSelecionados());
 }