本文整理汇总了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();
}
});
}
示例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);
}
示例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();
}