n音讯 - 播放的AudioFile,等待2秒,再次播放音频文件 [英] NAudio - Play an audiofile, wait for 2 seconds, play the audio file again
问题描述
我是新来n音讯C#,但我目前能够加载的音频文件,并在我的节目播放。现在,我要实现能够循环此音频文件但直到每2秒间隔后。我怎样才能做到这一点?
I'm new to NAudio c# but I am currently able to load an audio file and play it in my program. Now, I want to achieve being able to loop this audio file but not until after every 2 second interval. How can I achieve this?
推荐答案
有关的准确2秒的等待,我会创造我自己的 IWaveProvider
,在读
方法,从源文件中读取,那么当它完成后,返回2秒的沉默,然后开始从阅读重新开始的源文件。
For an accurate 2 second wait, I'd create my own IWaveProvider
that in the Read
method, read from your source file, then when it finished, returned 2 seconds of silence, and then started reading from the start of the source file again.
有关一个粗略的解决方案,你可以使用 PlaybackStopped
事件后,计时器火灾揭开序幕一个新的播放。
For a rough solution, you can just use a timer after the PlaybackStopped
event fires to kick off a new playback.
这篇关于n音讯 - 播放的AudioFile,等待2秒,再次播放音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!