Пример #1
0
        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
 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
        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
 public SongCallbackEventArgs(SongEntry entry)
 {
     this.entry = entry;
 }
Пример #7
0
 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));
 }