To set a sound card that you want to use for an audio preview you should get all the available audio devices and set the required one.
MPlatform SDK
Request the string with available audio renderer names from the MPreview object:
string strRenderersList; m_objPreview.PropsGet("audio_renderer.list", out strRenderersList);
It returns you a string that contains all the available audio devices divided by commas. For example, "Primary Sound Driver, Speakers (Cirrus Logic CS4206B (AB 40)), Digital Audio (S/PDIF) (Cirrus Logic CS4206B (AB 40))". You should parse the string split by commas and then choose the required device:
myPreview.PropsSet("audio_renderer", meSelectedAudioRenderer); // for example, "Digital Audio (S/PDIF) (Cirrus Logic CS4206B (AB 40))"
If new audio renderer devices going to be inserted into your system while an application running you should use the following property to get access to newly added devices.
//Reset audio_renderer device list for new device enumeration
m_objPreview.PropsSet("audio_renderer.reset", "true");
//Get updated renderer list
m_objPreview.PropsGet("audio_renderer.list", out strRenderersList);
MFormats SDK
Get a list of available audio renderers:
int nCount; m_objPreview.PropsOptionGetCount("audio_renderer", out nCount); if (nCount > 0) { for (int i = 0; i < nCount; i++) { string name, help; m_objPreview.PropsOptionGetByIndex("audio_renderer", i, out name, out help); comboBoxAudioRenderers.Items.Add(name); } }
This code returns you a list that contains all the available audio devices. For example, "Primary Sound Driver, Speakers (Cirrus Logic CS4206B (AB 40)), Digital Audio (S/PDIF) (Cirrus Logic CS4206B (AB 40))"
Set the required one:
m_objPreview.PropsSet("audio_renderer", myTargetName); // for example, "Digital Audio (S/PDIF) (Cirrus Logic CS4206B (AB 40))"