Reputation: 34036
i am trying to use Windows Media Foundation to play a simple video.
unfortunately there seems to be little documentation on how to do this.
actually i am using the sharpDX binding to accomplish this. but i would be happy about C++ samples as well.
here is what i have so far trying to follow this tutorial http://msdn.microsoft.com/en-us/library/windows/desktop/ms703190(v=vs.85).aspx
MediaManager.Startup();
MediaSession mediaSession;
MediaFactory.CreateMediaSession(null, out mediaSession);
SourceResolver sourceResolver;
MediaFactory.CreateSourceResolver(out sourceResolver);
ComObject comObject;
ObjectType objectType;
sourceResolver.CreateObjectFromURL("Jack.mp4", (int) SourceResolverFlags.None, null, out objectType, out comObject);
Topology topology;
MediaFactory.CreateTopology(out topology);
this runs without errors, but i havent figured out how to link this to a window or a texture so that i can actually see the video.
Upvotes: 0
Views: 5260
Reputation: 21966
If you can drop support of Windows 7, use IMFMediaEngine instead of sessions.
API documentation, sample code.
Don't forget to add D3D11_CREATE_DEVICE_VIDEO_SUPPORT flag to your D3D device, create IMFDXGIDeviceManager, and pass the manager to the engine in MF_MEDIA_ENGINE_DXGI_MANAGER attribute.
Upvotes: 3
Reputation: 69734
Windows SDK has a number of Media Foundation Samples (C++) in:
For example, MFPlayer2 Sample creates player linking it to video window:
HRESULT MFPlayer2::Initialize(HWND hwndVideo)
{
HRESULT hr = S_OK;
SafeRelease(&m_pPlayer);
hr = MFPCreateMediaPlayer(
NULL,
FALSE, // Start playback automatically?
0, // Flags
this, // Callback pointer
hwndVideo, // Video window
&m_pPlayer
);
Upvotes: 2