當前位置: 首頁>>代碼示例>>C#>>正文


C# WaveStream.Dispose方法代碼示例

本文整理匯總了C#中NAudio.Wave.WaveStream.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# WaveStream.Dispose方法的具體用法?C# WaveStream.Dispose怎麽用?C# WaveStream.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NAudio.Wave.WaveStream的用法示例。


在下文中一共展示了WaveStream.Dispose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DisposeInternal

        private void DisposeInternal(IWavePlayer player, WaveStream file)
        {
            new TaskFactory().StartNew(() => {
                if(player != null) {
                    player.Dispose();
                }

                if(file != null) {
                    // Given that the NAudio framework gives no access to inner systems the best way to
                    // assure the player has been disposed before disposing the file is to wait a while
                    Task.Delay(1000).Wait();
                    file.Dispose();
                }
            });
        }
開發者ID:GWigWam,項目名稱:SpeechMusicController,代碼行數:15,代碼來源:SongPlayer.cs

示例2: RunSession

    private void RunSession(WaveOut WaveOut, WaveStream stream, string match) {
      played.Add(match);
      WSRConfig.GetInstance().logInfo("PLAYER", "[" + device + "]" + "Start Player");
      Stopwatch timer = new Stopwatch(); timer.Start();

      using (WaveChannel32 volumeStream = new WaveChannel32(stream)) {
        volumeStream.Volume = match == "TTS" ? WSRConfig.GetInstance().SpkVolTTS / 100f : WSRConfig.GetInstance().SpkVolPlay / 100f;
        WaveOut.Init(volumeStream);
        WaveOut.Play();
        while (stream.CurrentTime < stream.TotalTime && played.Contains(match) && timer.ElapsedMilliseconds < 1000 * 60 * 8) {
          Thread.Sleep(100);
        }
        WaveOut.Stop();
        stream.Dispose();
      }

      WSRConfig.GetInstance().logInfo("PLAYER", "[" + device + "]" + "End Player");
      played.Remove(match);
    }
開發者ID:jdelhommeau,項目名稱:WSRMacro,代碼行數:19,代碼來源:WSRSpeaker.cs

示例3: Play

    private void Play(WaveStream stream, SpeakerState state) {
      
      // Stop all stream from playing for 1s
      if (DateTime.Now - StopTimeout < TimeSpan.FromMilliseconds(1000)) {
        Log("Stop next speech");
        state.playing = false;
        stream.Dispose();
        return;  
      }

      state.start = DateTime.Now;
      using (WaveChannel32 volume = new WaveChannel32(stream)) {
        volume.Volume = ConfigManager.GetInstance().Find("speaker.volume", 100) / 100f;
        waveOut.Init(volume);
        waveOut.Play();
        while (stream.CurrentTime < stream.TotalTime && (DateTime.Now - state.start) < state.timeout) { Thread.Sleep(500); }
        waveOut.Stop();
        state.playing = false;
      }
      stream.Dispose();
    }
開發者ID:JpEncausse,項目名稱:SARAH-Client-Windows,代碼行數:21,代碼來源:SpeakerManager.cs


注:本文中的NAudio.Wave.WaveStream.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。