Welcome to MSDN Blogs Sign in | Join | Help

Eric Anderson's Blog

A dollop of all things Media (Center | Extender | Player)
Building a playback app (DShow vs. MF vs. OCX)

If you want to add audio/video playback capabilities to your Windows application, you have several options to choose from. For tighter control, you can take advantage of the API exposed in lower-level infrastructure components, like DirectShow, the Format SDK, or Media Foundation. If you just want generic, universal playback functionality, you can use the WMP OCX.

I think it’s a common misconception that the OCX is only used for embedding in web pages, in places like gamespot.com or cnn.com. In fact, the OCX can be embedded in a standalone app and used solely for its playback infrastructure, without the user even knowing that it’s there. Media Center for example uses the OCX for some of its playback paths even though from the user perspective, you wouldn’t know that there are completely different pipelines being used when switching between DVD, TV, or WMV.

In Windows Vista, there are a lot of benefits to using MF, including enhanced glitch resilience. But there are still limitations in terms of the video formats supported natively in MF, and a simple intuitive programming model. DShow has been the defacto Windows A/V standard for the last several versions of Windows, but it doesn’t have a high-level API to program to, neither is it particularly resilient to system load in Windows Vista.

The OCX provides a sophisticated playback model that spans all the different pipelines, while maintaining a relatively easy API. Rollover is a big piece of functionality that the OCX provides, in that it will always choose the most optimal playback pipeline and then roll back as it needs to. The OCX also has some limitations in terms of overhead (namely playlist support) and trying to overlay text or other UI on top of the video (including if you try to use a non-rectangular video surface), but it is otherwise a solid mid-weight playback solution.

For future versions of Windows we’re looking at simplifying the playback story – making it easier to embed playback functionality into apps without having to deal with the complexities of different playback infrastructures  without some of the current limitations in the OCX.

 

11/2/06 Addendum:
I just came across a whitepaper that a coworker of mine wrote that goes into a bit more detail on this for those that are interested. I would’ve taken it a different direction - maybe started it off with a joke about three guys who go into a bar - but hey, it’s still a good write-up. Enjoy!
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/t_d_migrating_from_directshow_to_media_foundation__cyor.asp

Posted: Thursday, October 26, 2006 4:05 PM by errand

Comments

Anshul Rawal said:

I want to add video in my application and the video must play in the application without playing in media players, like in games in which video runs in the application with the little help from a player. Main thing how can I do that?

# December 30, 2007 5:21 AM

errand said:

Hey Anshul,

You can use the WMP OCX object in a windowless mode that could help you do this. Depending on how much control you want to overlay graphics or other things, you may have to write your own custom EVR presenter - but for simple cases of just media playback, look at windowless mode first. There is documentation on msdn for this.

Eric

# January 21, 2008 2:01 PM
Anonymous comments are disabled
Page view tracker