예제 #1
0
파일: Player.cs 프로젝트: ZYFDroid/MetroMP3
        void createPlayer(SongEntry entry)
        {
            tryStop();
            source                         = new AudioFileReader(entry.Path);
            SpectrumSampler                = new SampleAggregator(source, 512);
            meter                          = new BetterMeteringSampleProvider(SpectrumSampler);
            meter.StreamVolume            += Meter_StreamVolume;
            SpectrumSampler.FftCalculated += ((sender, earg) => { });
            SpectrumSampler.PerformFFT     = true;

            output = new WaveOut()
            {
                DesiredLatency = 1, NumberOfBuffers = meter.WaveFormat.SampleRate / 256
            };

            output.Init(meter);
            output.PlaybackStopped += Output_PlaybackStopped;
            totalPosition           = source.TotalTime;
            output.Volume           = volume / 100f;
            onPlayPauseChanged?.Invoke(this, EventArgs.Empty);
            clearSongInfo(entry);
            onInfoLoaded?.Invoke(null, new SongCallbackEventArgs(entry));
            Task getTask = new Task <SongEntry>(() => readAsync(entry));

            getTask.Start();
            getTask.ContinueWith(t => {
                onInfoLoaded?.Invoke(null, new SongCallbackEventArgs(entry));
            });
            onNewSong?.Invoke(null, EventArgs.Empty);
        }
예제 #2
0
파일: Player.cs 프로젝트: ZYFDroid/MetroMP3
 void clearSongInfo(SongEntry entry)
 {
     album  = "";
     artist = "";
     title  = Path.GetFileNameWithoutExtension(entry.Path);
     cover?.Dispose();
     cover = null;
 }
예제 #3
0
 private void tblFolders_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 2 && e.RowIndex >= 0)
     {
         SongEntry se = tblFolders[0, e.RowIndex].Value as SongEntry;
         loadList(se);
     }
 }
예제 #4
0
파일: Player.cs 프로젝트: ZYFDroid/MetroMP3
        void readSongInfo(SongEntry entry)
        {
            if (!entry.Path.EndsWith("mp3"))
            {
                return;
            }
            Id3.Mp3 mp3 = new Id3.Mp3(entry.Path, Id3.Mp3Permissions.Read);
            IEnumerable <Id3.Id3Tag> tags = mp3.GetAllTags();


            artist = "";

            foreach (var item in tags)
            {
                if (item.Album.IsAssigned && item.Album.Value.Trim('\0', '\n', '\r', ' ') != "")
                {
                    album = item.Album.Value.Trim();
                }
                if (item.Title.IsAssigned && item.Title.Value.Trim('\0', '\n', '\r', ' ') != "")
                {
                    title = item.Title.Value.Trim();
                }
                if (item.Artists.IsAssigned)
                {
                    foreach (var item2 in item.Artists.Value)
                    {
                        if (item2.Trim('\0', '\n', '\r', ' ') != "")
                        {
                            if (artist.Length > 0)
                            {
                                artist += ", ";
                            }
                            artist += item2.Trim('\0', '\n', '\r', ' ');
                        }
                    }
                }
                if (item.Pictures.Count > 0)
                {
                    foreach (var item2 in item.Pictures)
                    {
                        if (item2.IsAssigned)
                        {
                            using (MemoryStream ms = new MemoryStream(item2.PictureData)) {
                                cover = new Bitmap(ms);
                                break;
                            }
                        }
                    }
                }
            }
            mp3.Dispose();
        }
예제 #5
0
        void loadInfo(SongCallbackEventArgs e)
        {
            SongEntry current = Program.songsInFolder[Program.folders[FolderPos]][SongPos];

            Console.WriteLine("Load");
            if (e.Entry != current)
            {
                return;
            }
            lblAlbum.Text     = mPlayer.Album;
            lblArtist.Text    = mPlayer.Artist;
            lblSongName.Text  = mPlayer.Title;
            imgAlbum.Image    = mPlayer.Cover == null ? Properties.Resources.default_cover : mPlayer.Cover;
            lblTimeTotal.Text = mPlayer.TotalPosition.toTimeStr();
        }
예제 #6
0
파일: Player.cs 프로젝트: ZYFDroid/MetroMP3
 public SongCallbackEventArgs(SongEntry entry)
 {
     this.entry = entry;
 }
예제 #7
0
파일: Player.cs 프로젝트: ZYFDroid/MetroMP3
 SongEntry readAsync(SongEntry entry)
 {
     readSongInfo(entry);
     return(entry);
 }
예제 #8
0
 private void loadList(SongEntry parent)
 {
     tblSongs.Rows.Clear();
     Program.songsInFolder[parent].ForEach(f => tblSongs.Rows.Add(f, null, Path.GetFileName(f.Path), parent));
 }