C# – How to set output audio device for a movie in QuickTime SDK in C# when function isn’t exposed in Interop assembly

audiocinteropquicktime

I'm using the latest version of the QuickTime SDK and want to have the audio from the "movies" (they are referenced as movies but can be mp3, m4a, mov, and other filetypes) played through specific audio devices if the user has more than one audio device.

Apple has a couple functions in one of their samples that allow you to do this but they are in C++. I can't find the functions anywhere in the C# interop assemblies. They are SetMovieAudioContext, and QTAudioContextCreateForAudioDevice.

The sample documentation for calling these functions in C++ is listed at Technical FAQ: How can I render QuickTime Movie audio to a specific Audio Device once I have a Audio Device ID?.

Here's a sample .NET 2003 C++ program that does this using the audio device GUID: http://developer.apple.com/samplecode/QTSetMovieAudioDevice/index.html#//apple_ref/doc/uid/DTS10003897

How would I reference these in C# and be able to pass a Movie object into them to have it set the audio device context? Would I have to create a C++ dll that I call (would that even be possible)?

If you need the SDK, the Quicktime 7.3 SDK can be downloaded from https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=19910. It requires a free ADC account to download.

Any help would be greatly appreciated.

Thank you,

John

Best Answer

Wrapping native code in C# is often a long and arduous process (unless you are doing Windows API, when googling can usually provide the P/Invoke signatures). You either have to take the hit and create managed P/Invoke wrappers for all functions and structures used by the API in question, or you can use C++/CLI (available with Visual C++ Express Edition for free). With C++/CLI you can directly call your native code, and provide a simplified managed interface that your C# code can use.

Related Topic