当前位置: 首页>>代码示例>>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;未经允许,请勿转载。