0

I started to check the way how I can use NAudio to play sounds using different Output devices.

Now I would like to use NAudio for the following use case: I would like to play a ringback when a call arrives on a soft phone. The ringback audio (wav file of 3-5 sec) should be played repeatedly until the call is accepted or the caller hangs-up the call.

I found now two ways of doing it:

Following entry explains how this could be solved by playing a file in a loop: NAudio looping an audio file

Another entry explains how to work this out by using a timer to play the file repeatedly: NAudio - Play an audiofile, wait for 2 seconds, play the audio file again

The question is which way is the better one to go for? So does it make sense to start the playback often for a quite short-time?

Another question which arise is if there is way to make sure that in the looping case the playback is rellay stopped as it does not make sense to have the ringback played from the loudspeaker although the person is talking already to the caller.

Thank you very much for your support!

Uzay

Community
  • 1
  • 1
Uzay
  • 31
  • 4

1 Answers1

0

I'd recommend using the looping solution in this scenario. It avoids the need to keep closing and opening the soundcard. Stopping works exactly the same whether you are looping or not.

Mark Heath
  • 48,273
  • 29
  • 137
  • 194
  • Thank you very much for the answer. Do you think I can still take the LoopStream class to work with or is there meanwhile a better way for building up the loop? – Uzay Jun 21 '16 at 15:25
  • it should work just fine as is. For a short sound you could optimize by pre-loading into memory, but that is optional. – Mark Heath Jun 21 '16 at 17:43
  • Thank you very much - also for the great library you provided us! – Uzay Jun 22 '16 at 10:30