Exemplo n.º 1
0
        private void listViewTracks_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (files.Length == 1)
                {
                    string path = files[0];
                    try
                    {
                        CUESheet cue = new CUESheet(_config);
                        cue.Open(path);
                        for (int iTrack = 0; iTrack < cue.TrackCount; iTrack++)
                        {
                            DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
                                path,
                                cue.Metadata.Artist,
                                cue.Metadata.Tracks[iTrack].Title,
                                cue.Metadata.Title,
                                (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
                                iTrack + 1);
                            listViewTracks.Items.Add(ToItem(row));
                        }
                        cue.Close();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.Message);
                    }

                    FileInfo fi = new FileInfo(path);
                    if (fi.Extension != ".cue")
                    {
                        DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
                            path,
                            null,                          // cue.Artist,
                            null,                          // cue.Tracks[iTrack].Title,
                            null,                          // cue.Title,
                            0,                             // (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
                            0);
                        listViewTracks.Items.Add(ToItem(row));
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void PlayThread()
 {
     try
     {
         do
         {
             if (playingSource == null)
             {
                 writer.Pause();
             }
             else
             {
                 if (seekTo >= 0 && playingStart + seekTo < playingFinish)
                 {
                     playingSource.Position = playingStart + seekTo;
                     seekTo = -1;
                 }
                 if (playingSource.Position == playingFinish || stopNow || seekTo == (int)(playingFinish - playingStart))
                 {
                     seekTo = -1;
                     playingSource.Close();
                     playingSource = null;
                     if (playingCue != null)
                     {
                         playingCue.Close();
                         playingCue = null;
                     }
                     playingFinish = 0;
                     playingStart  = 0;
                     playingRow    = -1;
                     if (stopNow || nextDeck == null || nextDeck.playingSource == null)
                     {
                         writer.Flush();
                         stopNow = false;
                         mixer.BufferPlaying(iSource, false);
                         needUpdate = true;
                         playThread = null;
                         return;
                     }
                     playingSource          = nextDeck.playingSource;
                     playingCue             = nextDeck.playingCue;
                     playingStart           = nextDeck.playingStart;
                     playingFinish          = nextDeck.playingFinish;
                     playingRow             = nextDeck.playingRow;
                     needUpdate             = true;
                     nextDeck.playingSource = null;
                     nextDeck.playingCue    = null;
                     nextDeck.playingStart  = 0;
                     nextDeck.playingFinish = 0;
                     nextDeck.playingRow    = -1;
                     nextDeck.needUpdate    = true;
                 }
                 if (buff == null || buff.PCM.SampleRate != playingSource.PCM.SampleRate || buff.PCM.ChannelCount != playingSource.PCM.ChannelCount || buff.PCM.BitsPerSample != playingSource.PCM.BitsPerSample)
                 {
                     buff = new AudioBuffer(playingSource.PCM, 0x2000);
                 }
                 playingSource.Read(buff, Math.Min(buff.Size, (int)(playingFinish - playingSource.Position)));
                 writer.Write(buff);
             }
         } while (true);
     }
     catch (Exception ex)
     {
     }
     if (playingCue != null)
     {
         playingCue.Close();
         playingCue = null;
     }
     if (playingSource != null)
     {
         playingSource.Close();
         playingSource = null;
     }
     playThread = null;
 }