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


C# WaveFileReader.Seek方法代碼示例

本文整理匯總了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();
            }
        }
開發者ID:vserrago,項目名稱:LiveDescribe-Desktop,代碼行數:27,代碼來源:DescriptionPlayer.cs


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