Hello, this is probably the wrong repository, but I don't know where to ask.
I'm trying to make my app compatible with Windows N as there Windows.Media namespace is (mostly?) unavailable if users don't install the "Media Feature Pack" optional feature from system preferences.
Now, I guess that I could simply try-catch new MediaPlayer() and store a flag somewhere but I wonder if there's any better way to do this.
I tried to use ApiInformation.IsTypePresent but this obviously doesn't work.
I also would like to have ability to inform user about missing functionality in application, if Media Feature Pack is not installed.
@MikeHillberg and @jonwis for FYI
Can you transfer this to http://github.com/microsoft/ProjectReunion ? This is a general question I'm sure we can help you figure out. Thanks!
If you make a call to MFStartup and Media Foundation is not available (as on N-SKU) it will return E_NOTIMPL for N-SKU. If you are writing your app in a language besides C/C++ you'll need to create a WinRT component in C++ that makes the call and returns true or false.
You will need to make sure that you delay load mf.dll.
@DavidS-msft
Can't I use DllImport for that from C#?
Code below seems to work at least with S_OK result.
[DllImport("mfplat.dll", ExactSpelling = true, PreserveSig = false)]
public static extern uint MFStartup(int version, int dwFlags = 0);
const int MF_SDK_VERSION = 0x02;
const int MF_API_VERSION = 0x70;
const int MF_VERSION = (MF_SDK_VERSION << 16) | MF_API_VERSION;
const int MFSTARTUP_FULL = 0;
const uint S_OK = 0;
const uint MF_E_BAD_STARTUP_VERSION = 0xC00D36E3;
const uint MF_E_DISABLED_IN_SAFEMODE = 0xC00D36EF;
const uint E_NOTIMPL = 0x80004001;
var result = MFStartup(MF_VERSION, MFSTARTUP_FULL);
if (result == E_NOTIMPL) { /* prompt user to install missed features */ }
I actually implemented it in C++, but I can give a try to your code @maxkatz6 today (I have a N VM). Btw, make sure to call MFShutdown if the result is S_OK.
@FrayxRulez thanks! It would be really useful.
Most helpful comment
If you make a call to MFStartup and Media Foundation is not available (as on N-SKU) it will return E_NOTIMPL for N-SKU. If you are writing your app in a language besides C/C++ you'll need to create a WinRT component in C++ that makes the call and returns true or false.
You will need to make sure that you delay load mf.dll.