1

A while back I was working on an application that controls the sound output of programs based on which screen the program is. For example I have a browser on my TV and by that I want to set the sound output of the program to the TV's speakers. I've already done the detection part (find on which screen the program is) and I'm ready to implement any solutions you give me here. My program works by always following the application that is focused, so if it changes screens it should change sound output

As I told you above, I already have the screen detection done but when it comes to changing the sound output for only that application that is focused I had no luck so far. How do I accomplish this? Is it possible? I've already searched on this topic and found libraries that should do this like NAudio but none of them seemed to work for me, that's why I stopped developing this program, until now :)

halfer
  • 19,824
  • 17
  • 99
  • 186
DavidAnastasov
  • 63
  • 1
  • 10
  • @Michael Gunter yes I've already seen this thread but none of the answers there worked for me, on the other hand is it possible to make a virtual sound card and hook all the programs to it and through that sound card to relay the programs to the sound outputs, I haven't researched this as it only came as an idea rn – DavidAnastasov Apr 20 '18 at 21:09
  • Are you running Windows 10? If so, you're encountering the same thing I found -- some of the answers in that thread (and referenced threads) seem to work (no errors) but actually just don't do anything at all. I don't know if a virtual soundcard would work or not, but if it does, it'll be quite a lot of work. You'll have to build a whole driver for it. – Michael Gunter Apr 20 '18 at 21:12

1 Answers1

2

Unfortunately, you're screwed. Windows intentionally provides no API to change the default audio output device. It was determined long ago that such an API would allow developers to write programs that were highly intrusive and annoying to the user.

Throughout the years, people have discovered some undocumented features of Windows that would allow this. I had it working pretty consistently on my old Windows 7 box. However, the programs I wrote to do that no longer work on Windows 10, and I have never been able to find any other mechanism that would do it.

Here's another question that has some good references: Programmatically switch audio devices on Windows 7

Michael Gunter
  • 12,528
  • 1
  • 24
  • 58