コード例 #1
0
            public void Play(string filePath)
            {
                if (Path.GetExtension(filePath) == ".ogg")
                {
                    waveOutDevice = new WaveOut();
                    waveOutDevice.PlaybackStopped += new EventHandler<StoppedEventArgs>(waveOutDevice_PlaybackStopped);

                    vorbisReader = new VorbisWaveReader(filePath);
                    audioReader = null;
                    waveOutDevice.Init(vorbisReader);

                    waveOutDevice.Play();
                }
                else
                {
                    if (waveOutDevice != null)
                    {
                        waveOutDevice.Stop();
                        waveOutDevice.Dispose();
                    }

                    waveOutDevice = new WaveOut();
                    waveOutDevice.PlaybackStopped += new EventHandler<StoppedEventArgs>(waveOutDevice_PlaybackStopped);

                    vorbisReader = null;
                    audioReader = new AudioFileReader(filePath);
                    waveOutDevice.Init(audioReader);

                    waveOutDevice.Play();
                }
            }
コード例 #2
0
        public NAudioPlaying(NAudioSource Source)
        {
            lock (Source)
            {
                FromSource = Source;
                Wave = Source.outWave;
                WStream = new VorbisWaveReader(Source.sFileName);

                Wave.Init(WStream);

                Wave.PlaybackStopped += wave_PlaybackStopped;

                Wave.Play();
                //FromSource.ConnectedDriver.Mixer.AddInputStream(WStream);
                FromSource.ConnectedDriver.RaisePlay(this);
            }
        }