本文整理汇总了C#中IWavePlayer.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# IWavePlayer.Pause方法的具体用法?C# IWavePlayer.Pause怎么用?C# IWavePlayer.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWavePlayer
的用法示例。
在下文中一共展示了IWavePlayer.Pause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: playSong
/// <summary>
/// Method that plays whatever the current song is
/// </summary>
private void playSong()
{
skipThis = false;
Stream stream = Subsonic.StreamSong(currentSong.id);
// Try to move this filling of memory stream into the background...
Stream ms = new MemoryStream();
byte[] buffer = new byte[32768];
int read;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
playerThread.ReportProgress(50);
ms.Write(buffer, 0, read);
}
ms.Position = 0;
Mp3FileReader mp3Reader = new Mp3FileReader(ms);
WaveStream blockAlignedStream =
new BlockAlignReductionStream(
WaveFormatConversionStream.CreatePcmStream(mp3Reader));
WaveOut waveOut;
waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
waveOut.Init(blockAlignedStream);
waveOut.Play();
playState = PlaybackState.Playing;
bool songEnd = false;
while (playState != PlaybackState.Stopped && !songEnd && !skipThis)
{
if (waveOut.PlaybackState == PlaybackState.Stopped)
songEnd = true;
else
{
switch (playState)
{
case PlaybackState.Paused:
waveOut.Pause();
break;
case PlaybackState.Playing:
if (waveOut.PlaybackState != PlaybackState.Playing)
waveOut.Play();
else
{
int progress = (int)(100.0 * mp3Reader.CurrentTime.TotalSeconds / mp3Reader.TotalTime.TotalSeconds);
playerThread.ReportProgress(progress);
Thread.Sleep(100);
}
break;
default:
break;
}
}
}
//if (playState == PlaybackState.Stopped)
waveOut.Stop();
//waveOut.Dispose();
}