This project has moved and is read-only. For the latest updates, please go here.

Line out/headphone playback problem

Jul 28, 2013 at 7:29 PM
Using WaveOutEvent, i can play a song just fine through Line Out on a laptop (headphones)

My first problem came when unpluging while playing. The playback stopped and program froze. After some forum searching, i found the solution through the PlaybackStopped event on WaveOutEvent, i just started the same song at the last position, problem solved.

But, if i play through the speakers and plugs in the headphones, there is no sound. If i unplug, the speakers play again. The same happens, after my first solution, if i start with headphones in, unplugges, and the playback is reinitiated through the fix and plugges them in again, there is no sound. Only through speakers.

Am i missing something? my guess is that i need to reinitiate the playback when plugging in the headphones, but how would i know when to do that?
Jul 29, 2013 at 11:07 PM
I think there is a WIndows audio API that lets you know when the default playback device has changed (somewhere in the WASAPI API), but I haven't used it myself so I don't know it off the top of my head. You'd need to browse the MSDN documentation and see if you can find it, then have a look at the NAudio wrappers and see if you can call it.