Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
How to play audio on a loop using NAudio library?

I wrote some code that sets new playlist each time at fixed intervals and then plays it, but after the first play, it doesn't play anymore. I still get 55 printed in the console, so my code is running, it's just the player stops working.

if (AlarmSystem.OutputDevice.PlaybackState != PlaybackState.Playing)
{
  var playlist = new ConcatenatingSampleProvider(AlarmSystem.GetTriggeredAlarmsPlaylist());
  AlarmSystem.OutputDevice.Init(playlist);
  AlarmSystem.OutputDevice.Play();

  Console.WriteLine(55);
}

I checked the audio playback also seems to be interrupted even though I am checking for PlaybackState and only run the above code if it's not PlaybackState.Playing.

I tried calling Dispose before also and even recreating OutputDevice but it doesn't play again.

In my code I am getting the new playlist so I can play that one after the old one finishes.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!