当前位置: 首页>>代码示例>>C#>>正文


C# IWavePlayer.Play方法代码示例

本文整理汇总了C#中IWavePlayer.Play方法的典型用法代码示例。如果您正苦于以下问题:C# IWavePlayer.Play方法的具体用法?C# IWavePlayer.Play怎么用?C# IWavePlayer.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWavePlayer的用法示例。


在下文中一共展示了IWavePlayer.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PianoSynth

        public PianoSynth()
        {
            mixer = new WaveMixerStream32();
            mixer.AutoStop = false;

            int i = 0;
            foreach (var note in noteFiles)
            {
                reader[i] = new WaveFileReader(note);

                offsetStream[i] = new WaveOffsetStream(reader[i]);
                channelSteam[i] = new WaveChannel32(offsetStream[i]);
                channelSteam[i].Position = channelSteam[i].Length;
                mixer.AddInputStream(channelSteam[i]);

                i++;
            }

            if (waveOutDevice == null)
            {
                waveOutDevice = new WaveOut {DeviceNumber = 0};
                waveOutDevice.Init(mixer);
                waveOutDevice.Volume = 0;
                waveOutDevice.Play();
                waveOutDevice.Volume = 100;
            }
        }
开发者ID:grazulis,项目名称:KinectRainbowSynth,代码行数:27,代码来源:PianoSynth.cs

示例2: Connect

        private void Connect(IPEndPoint endPoint, int inputDeviceNumber, INetworkChatCodec codec)
        {
            waveIn = new WaveIn();
            waveIn.BufferMilliseconds = 50;
            waveIn.DeviceNumber = inputDeviceNumber;
            waveIn.WaveFormat = codec.RecordFormat;
            waveIn.DataAvailable += waveIn_DataAvailable;
            waveIn.StartRecording();

            udpSender = new UdpClient();
            udpListener = new UdpClient();

            // To allow us to talk to ourselves for test purposes:
            // http://stackoverflow.com/questions/687868/sending-and-receiving-udp-packets-between-two-programs-on-the-same-computer
            udpListener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            udpListener.Client.Bind(endPoint);

            udpSender.Connect(endPoint);

            waveOut = new WaveOut();
            waveProvider = new BufferedWaveProvider(codec.RecordFormat);
            waveOut.Init(waveProvider);
            waveOut.Play();

            connected = true;
            var state = new ListenerThreadState { Codec = codec, EndPoint = endPoint };
            ThreadPool.QueueUserWorkItem(ListenerThread, state);
        }
开发者ID:LibertyLocked,项目名称:NAudio,代码行数:28,代码来源:NetworkChatPanel.cs

示例3: playWave

 /// <summary>
 /// Lejátszik egy .mp3 fájlt
 /// </summary>
 /// <param name="audioFile">.mp3 fájl</param>
 public static void playWave(string audioFile)
 {
     thread = new WaveOut();
     stream = CreateInputStream(audioFile);
     thread.Init(stream);
     thread.Play();
 }
开发者ID:Easimer,项目名称:bearded-spider,代码行数:11,代码来源:Audio.cs

示例4: play_Click

        private void play_Click(object sender, EventArgs e)
        {
            if (playlist.SelectedItems.Count>0)
            {
                id = fn.IndexOf(playlist.SelectedItem.ToString());
                if (waveOutDevice.PlaybackState.ToString() != "Paused")
                {
                    t.Stop();
                    stp();
                    audioFileReader = new AudioFileReader(fp[id]);
                    waveOutDevice = new WaveOut();
                    waveOutDevice.Init(audioFileReader);
                    trackbar.Maximum = (int)audioFileReader.TotalTime.TotalSeconds + 1;
                    //deb.Items.Add(audioFileReader.TotalTime.Seconds.ToString());
                    audioFileReader.Volume = (float)vol.Value / 100;
                    waveOutDevice.Play();
                    t.Start();

                }
                else
                {
                    waveOutDevice.Play();
                    t.Start();
                }
            }
            
           
            
        }
开发者ID:npuMa94,项目名称:npuMathecreator,代码行数:29,代码来源:Form1.cs

示例5: AudioPlaybackEngine

 public AudioPlaybackEngine(int sampleRate = 44100, int channelCount = 2)
 {
     outputDevice = new WaveOutEvent();
     mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channelCount));
     mixer.ReadFully = true;
     outputDevice.Init(mixer);
     outputDevice.Play();
 }
开发者ID:carsonk,项目名称:MistyMixer,代码行数:8,代码来源:AudioPlaybackEngine.cs

示例6: PlayFile

 public int PlayFile(string filename)
 {
     waveOutDevice = new WaveOut();
     mainOutputStream = CreateInputStream(filename);
     waveOutDevice.Init(mainOutputStream);
     waveOutDevice.Play();
     return 0;
 }
开发者ID:jorik041,项目名称:soundfingerprinting,代码行数:8,代码来源:NAudioService.cs

示例7: PlaySong

 public void PlaySong()
 {
     // Instantiate audio player
     waveOutDevice = new WaveOut();
     // Set MP3 to play
     audioFileReader = new AudioFileReader(GetSong());
     // Init device and call play
     waveOutDevice.Init(audioFileReader);
     waveOutDevice.Play();
 }
开发者ID:Brendo311,项目名称:AlarmClockWakeTheFuckUp,代码行数:10,代码来源:SoundAlarm.cs

示例8: BeginPlayback

 private void BeginPlayback(string filename)
 {
     Debug.Assert(wavePlayer == null);
     wavePlayer = CreateWavePlayer();
     audioFileReader = new AudioFileReader(filename);
     audioFileReader.Volume = volumeSlider1.Volume;
     wavePlayer.Init(audioFileReader);
     wavePlayer.PlaybackStopped += OnPlaybackStopped;
     wavePlayer.Play();
     EnableButtons(true);
     timer1.Enabled = true; // timer for updating current time label
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:12,代码来源:SimplePlaybackPanel.cs

示例9: Play

 private void Play()
 {
     if (waveOut != null)
     {
         Stop();
     }
     waveOut = new WaveOut();
     this.patternSequencer = new DrumPatternSampleProvider(pattern);
     this.patternSequencer.Tempo = tempo;
     waveOut.Init(patternSequencer);
     waveOut.Play();
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:12,代码来源:DrumMachineDemoViewModel.cs

示例10: button_play_Click

 //Кнопка "Плей"
 private void button_play_Click(object sender, EventArgs e)
 {
     button_stop.Enabled = true;
     timer.Start();
     ind = 2;
     waveOutDevice = new WaveOut();
     mainOutputStream = CreateInputStream(outputFilename);
     waveOutDevice.Init(mainOutputStream);
     waveOutDevice.Play();
     button_play.Enabled = false;
     button_rec.Enabled = false;
     numeric.Enabled = false;
 }
开发者ID:sylion,项目名称:Dikto,代码行数:14,代码来源:Form1.cs

示例11: play

 /// <summary>
 /// Joue le morceau
 /// </summary>
 public void play()
 {
     if (this.data != null)
     {
         terminated = false;
         outer = new WaveOut();
         outer.Init(this.data);
         outer.Play();
         outer.PlaybackStopped += outer_PlaybackStopped;
     }
     else
         this.load(true);
 }
开发者ID:chaipokoi,项目名称:Bourdon,代码行数:16,代码来源:SoundCloud.cs

示例12: play

 /// <summary>
 /// Joue le morceau
 /// </summary>
 public void play()
 {
     if (data != null || this.lastPlayed.AddMinutes(13) < DateTime.Now)
     {
         terminated = false;
         Console.WriteLine("Playing " + link);
         outer = new WaveOut();
         outer.Init(this.data);
         outer.Play();
         outer.PlaybackStopped += outer_PlaybackStopped;
     }
     else
         this.load(true);
 }
开发者ID:chaipokoi,项目名称:Bourdon,代码行数:17,代码来源:Youtube.cs

示例13: Start

        public void Start()
        {
            _audioSource.Listening = true;
            if (_audioSource.WaveOutProvider != null)
            {
                _waveOut = new DirectSoundOut(100);
                _waveOut.Init(_audioSource.WaveOutProvider);
                _waveOut.Play();

                _audioSource.DataAvailable -= AudioSourceDataAvailable;
                _audioSource.DataAvailable += AudioSourceDataAvailable;
                _bTalking = true;
            }
        }
开发者ID:WesleyYep,项目名称:ispyconnect,代码行数:14,代码来源:TalkLocal.cs

示例14: PlayKillStreak

        public IWavePlayer PlayKillStreak(string sfxName, string ext = "wav")
        {
            KillStreakDevice = KillStreakDevice ?? new WaveOutEvent();

            var path = SFXPath + sfxName + "." + ext;
            Wait(250);
            AudioFileReader audioFileReader = new AudioFileReader(path);
            audioFileReader.Volume = 0.6f * Volume;

            KillStreakDevice.Stop();
            KillStreakDevice.Init(audioFileReader);
            KillStreakDevice.Play();
            return KillStreakDevice;
        }
开发者ID:jonnelfernandez,项目名称:GTARPG,代码行数:14,代码来源:AudioHandler.cs

示例15: button_play_Click

        private void button_play_Click(object sender, EventArgs e)
        {
            if (!System.IO.File.Exists(textBox_filename.Text))
            {
                MessageBox.Show("Please select a valid file to play.");
                return;
            }

            waveOutDevice = new WaveOut();

            mainOutputStream = CreateInputStream(textBox_filename.Text);

            waveOutDevice.Init(mainOutputStream);
            waveOutDevice.Play();
        }
开发者ID:dolvlo,项目名称:ssamplerates,代码行数:15,代码来源:Form1.cs


注:本文中的IWavePlayer.Play方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。