Answered by:
Multiple audio output devices

Question
-
Hi,
It looks like we can ennumerate the audio devices available on the system, but is there any way to actually choose which audio device a MediaElement/MediaPlayer is rendering its output to? I cannot find any way to specify a device, and that is an absolute requirement for our app, since we need to play audio concurrently on multiple audio devices (could be one stream to USB headphones, another to normal speakers). Is this possible somehow, and if not, is it something you would consider adding before release?
- Edited by Thomas Darling Thursday, October 20, 2011 12:56 AM
Thursday, October 20, 2011 12:56 AM
Answers
-
There is no high level audio way to do this. Matthew van Eerde answer is correct. Xaudio2 might also be a possibility however it is also low level.
Best Wishes - Eric
- Marked as answer by Eric Hanson-MSFTModerator Tuesday, June 5, 2012 3:33 AM
Tuesday, June 5, 2012 3:33 AMModerator
All replies
-
Can you provide us more information on what you are trying to accomplish in your application? Is this a dj type application?
thanks
Frank
Thursday, October 20, 2011 5:41 PMModerator -
Exactly. We are essentially building an easy-to-use DJ application - one that is tailored for casual and semiprofessional users. I definitely see the value in providing simplified audio playback for the vast majority of apps, but for this type of application, there is no way it can work well without multiple audio outputs.
While the music is playing for everyone else, our user must be able to listen to a preview of a song/mix through headphones, without interrupting the music for everyone else. As far as I can tell, there is currently no way to do this - even the available subset of Media Foundation seems to lag this functionality.
There is such great device support everywhere else in this platform, so this limitation is really unfortunate, and as it stands right now, it pretty much blocks any further development for us. It may not be the most common scenario, but there is a whole class of really awesome apps that just cannot work without it, so I really hope it is something that can be resolved.
Something as simple as a MediaElement constructor that takes a device ID could solve the whole problem for us, and I think that would be a really good place to begin. That said, if we could also, in addition to that, get back the Media Foundation support for selecting audio devices, then it would be just perfect.
- Edited by Thomas Darling Thursday, October 20, 2011 11:36 PM
Thursday, October 20, 2011 11:35 PM -
You can use WASAPI to play to a non-default audio device in a Metro app.
Call Windows::Media::MediaDevice::GetAudioRenderSelector() to get a string that represents "all audio render devices"
Pass this string to Windows::Devices::DeviceInformation::FindAllAsync(...) to get a collection of audio render devices
Choose the audio device you want to use
Extract the id for this device
Call ActivateAudioInterface(id->Data, __uuidof(IAudioClient2), &pAudioClient2) to activate an IAudioClient2 on this interface
EDIT: actually use ActivateAudioInterfaceAsync rather than ActivateAudioInterface.
Matthew van Eerde- Proposed as answer by Frank K [MSFT]Microsoft employee, Moderator Monday, October 24, 2011 2:41 AM
- Marked as answer by Thomas Darling Tuesday, October 25, 2011 9:55 PM
- Unmarked as answer by Thomas Darling Tuesday, October 25, 2011 9:55 PM
- Unproposed as answer by Thomas Darling Thursday, November 10, 2011 4:34 AM
- Marked as answer by Eric Hanson-MSFTModerator Tuesday, June 5, 2012 3:28 AM
- Unmarked as answer by Eric Hanson-MSFTModerator Tuesday, June 5, 2012 3:29 AM
- Edited by Maurits [MSFT]Microsoft employee Tuesday, June 5, 2012 10:26 PM
Friday, October 21, 2011 5:23 PM -
Ahh, thanks, that could work, although it seems to be a very low-level solution to something that we really do feel is missing in the higher-level API's.
What if we want to support playing a video (eg. music videos) using a non-default audio device, could that be done, while still keeping everything in sync?After looking a little more into the options, we found that this might be a good solution for our scenario:
However, we also found this comment hiding in one of the samples:
// * CreateMasteringVoice now takes a device id string instead of index, requiring you to enumerate devices using
// the new modern device enumeration APIs in Windows or the desktop MMDevice enumeration APIs
// (Only the default device is supported for //BUILD.)So, would this API be a viable solution, that we can count on being available?
And if so, can you say anything about when we might be able to actually start using it with multiple audio devices?Tuesday, October 25, 2011 10:23 PM -
Hi, is there any news on this?Tuesday, November 8, 2011 11:39 PM
-
Is this still an issue for you?
Best Wishes - Eric
- Proposed as answer by Eric Hanson-MSFTModerator Wednesday, May 23, 2012 8:59 PM
Saturday, March 17, 2012 2:18 AMModerator -
Have you looked into XAudio2?
- Marked as answer by Eric Hanson-MSFTModerator Wednesday, May 23, 2012 9:00 PM
- Unmarked as answer by Eric Hanson-MSFTModerator Wednesday, May 23, 2012 9:00 PM
- Proposed as answer by Eric Hanson-MSFTModerator Wednesday, May 23, 2012 9:00 PM
Wednesday, May 23, 2012 9:00 PMModerator -
There is no high level audio way to do this. Matthew van Eerde answer is correct. Xaudio2 might also be a possibility however it is also low level.
Best Wishes - Eric
- Marked as answer by Eric Hanson-MSFTModerator Tuesday, June 5, 2012 3:33 AM
Tuesday, June 5, 2012 3:33 AMModerator