本文整理匯總了C#中NAudio.Wave.WaveFileReader.Seek方法的典型用法代碼示例。如果您正苦於以下問題:C# WaveFileReader.Seek方法的具體用法?C# WaveFileReader.Seek怎麽用?C# WaveFileReader.Seek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NAudio.Wave.WaveFileReader
的用法示例。
在下文中一共展示了WaveFileReader.Seek方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PlayAtOffset
/// <summary>
/// Plays a description, beginning from a time offset from the beginning of the wav file.
/// </summary>
/// <param name="description">Description to play.</param>
/// <param name="offset">How far into the description to start playing at.</param>
private void PlayAtOffset(Description description, double offset)
{
lock (_playLock)
{
var reader = new WaveFileReader(description.AudioFile);
//reader.WaveFormat.AverageBytesPerSecond/ 1000 = Average Bytes Per Millisecond
//AverageBytesPerMillisecond * (offset + StartWaveFileTime) = amount to play from
reader.Seek((long)((reader.WaveFormat.AverageBytesPerSecond / 1000)
* (offset + description.StartWaveFileTime)), SeekOrigin.Begin);
var descriptionStream = new WaveOutEvent();
descriptionStream.PlaybackStopped += DescriptionStream_PlaybackStopped;
descriptionStream.Init(reader);
DescriptionStream = descriptionStream;
_playingDescription = description;
IsPlaying = true;
_playingDescription.IsPlaying = true;
descriptionStream.Play();
}
}