MFCreateMediaSession not supported for Metro apps?
-
18. dubna 2012 1:43I'm learning Media Foundation and would like to use it from my own Metro apps. Unfortunately, MFCreateMediaSession is not supported for Metro apps. Why is that? How would a Metro app create a media session to, say, play a stream of PCM audio generated on the fly by the app?
Všechny reakce
-
19. dubna 2012 7:32Moderátor
Hello,
Did you want to use MFCreateMediaSession to create playlist?
If so, you can use Windows.Media.Playlists namespace to instead of it
http://msdn.microsoft.com/library/windows/apps/BR206938There is the sample codes
http://code.msdn.microsoft.com/windowsapps/Playlist-sample-3d80daeeBest regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
-
19. dubna 2012 18:53No, I don't want to create a playlist. I want to play a stream of PCM audio generated on the fly by the app. This means my app creates the audio samples using an algorithm, and it runs continuously. There is no file, no audio format, just plain audio samples.
-
19. dubna 2012 21:23Moderátor
Hello rwalters,
Here are two options for you:
1) Use WASAPI and pump your synthesized PCM audio directly to the audio manager (preferred)
2) Create a custom source that can plug into the Media Foundation Media Engine
Either approach will work as expected. You will need to carefully review each method and compare them against your software requirements. For most synthesized audio scenarios, using the WASAPI is recommended.
Win32 and COM for Metro style apps (multimedia)
http://msdn.microsoft.com/en-us/library/windows/apps/hh452756.aspxReal-time communication sample
http://code.msdn.microsoft.com/windowsapps/Simple-Communication-Sample-eac73290I hope this helps,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Navržen jako odpověď James Dailey - MSFTMicrosoft Employee, Moderator 19. dubna 2012 21:28
- Zrušeno navržení jako odpověď rwalters 23. dubna 2012 17:10
- Označen jako odpověď rwalters 23. dubna 2012 22:00
-
19. dubna 2012 22:13
Thanks James, but I find the "Win32 and COM for Metro style apps (multimedia)" reference confusing and unhelpful. It's really only a list of functions that I can call from a Metro app. What about the ones I can't?
More specific questions on the two options proposed:
1) WASAPI: I'm missing one crucial piece in my understanding -- how to do the initial activation/instantiation of the required objects to access audio devices. How do I even get a handle to an audio device when IMMDevice isn't supported for Metro style apps?
2) Media Foundation Media Engine: from studying the real-time communication sample, it seems the approach for play/record would be the following -- have I got it right so far?
- Playback: Use Windows.Media.MediaExtensionManager to register a scheme (in the example, it's "stsp://") handler which creates a custom source whenever a URL with this scheme is navigated to.
- Recording: Implement a custom sink and use Windows.Media.Capture.MediaCapture.StartRecordToCustomSinkAsync to capture media to it.
- Upravený rwalters 19. dubna 2012 22:59 Expanded upon original post, added more specific questions
- Playback: Use Windows.Media.MediaExtensionManager to register a scheme (in the example, it's "stsp://") handler which creates a custom source whenever a URL with this scheme is navigated to.
-
23. dubna 2012 17:13I'm unproposing as answer, for now, to get more attention. Option #1 was sufficiently vague, given nobody seems to know how to do it in a Metro app (no examples, factories and interfaces such as IMMDevice not available to Metro apps, etc.) I'll gladly mark it as an answer again if I could get clarification. Thanks!
-
23. dubna 2012 21:21Moderátor
Hello rwalters,
Here are the answers to your questions:
Q. How do I even get a handle to an audio device when IMMDevice isn't supported for Metro style apps?
A. Code listed below:Platform::String^ id = Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId(Windows::Media::Devices::AudioDeviceRole::Console ); Microsoft::WRL::ComPtr<IAudioClient> pAudioClient = NULL; ActivateAudioInterface( id->Data(), __uuidof( IAudioClient ), (void**)&pAudioClient );
Q. ...it seems the approach for play/record would be the following -- have I got it right so far?
A. Yes this seems like a reasonable approach.I hope this helps,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Navržen jako odpověď James Dailey - MSFTMicrosoft Employee, Moderator 23. dubna 2012 21:21
- Označen jako odpověď rwalters 23. dubna 2012 22:15
-
23. dubna 2012 21:45Thanks for the code example! Where can I learn more about ActivateAudioInterface()? I can't seem to find it in the MSDN or Dev Center. The only hits when I search for it are here in the forums...
-
27. dubna 2012 0:33Moderátor
I agree that is a big problem that we are trying to fix.
-James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
-
4. května 2012 20:50Bumping this. I'm working on a WinRT component in C++. Trying to use ActivateAudioInterface results in an unresolved symbol. What am I doing wrong?
-
7. května 2012 23:06Moderátor
Hello Tom,
Try "mmdeviceapi.h". If that doesn't work let me know.
-James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
-
9. října 2012 12:21
I'm newbie in this section, and I have another questions about SimpleCommunication sample and custom media sink:
- Can I get each picture in video stream while it is recording?
- Can I change framerate and resolution of video stream while it is recording to custom media sink?
- If I can get pictures from the video stream, can I edit it and fill it again in video stream?
Thanks