1

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?

Cheena
  • 19
  • 2
  • 1
    first. search in google something like this https://www.google.com/search?q=how+to+do+something+every+2+seconds+c%23&ie=utf-8&oe=utf-8 then you probably find something like this http://stackoverflow.com/questions/6169288/execute-specified-function-every-x-seconds good luck! – M.kazem Akhgary Oct 27 '15 at 14:20

2 Answers2

1

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.

For a rough solution, you can just use a timer after the PlaybackStopped event fires to kick off a new playback.

Mark Heath
  • 48,273
  • 29
  • 137
  • 194
0

Make a timer into your loop's end. Make it sleep for a while.

Execute specified function every X seconds

It has been explained here before.

Community
  • 1
  • 1