Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / MFC

DShow based player

2.19/5 (16 votes)
15 Jul 2008CPOL2 min read 3   613  
a media file player based on DShow

Introduction

It's simple player, don't expect much.
DirectShow is the ideal media engine, if that the only thing you required is playback. Here is a sample player built on DShow.

Background

DShow consist of core engine and optional components, all exist as DLLs. They are exposed via COM interfaces. Thus COM technology is required. As well as that DirectX9.0c SDK is required to compile the code. Note: 9.0c is the newest and best version for VC6. You can try other version of DXSDK if you don't use VC6. (But no warranty that it would work.)
The core engine uses suplies the control all through. The optinal components classified by purpose. Those used to read media file/source are Parsers. Similarly, Decoders used to restore audio/video back to it's orignal form. Renderers show video picture or play sound for audio.
Normally, all you need for playing a given media file is that: the decoder(s). Other else have already installed on Windows system.
Follow the rule of DShow, media types are registered into Registry as GUIDs. Find out the appropriate parse the decoder for the media file, push the media data into the renderer, that all for the game of playing. It sounds easy, isn't it?

Using the code

The core engine has been capsulated(wrapped) as a single class: CPlayer. Render a media file by create DShow engine, then you're ready to play!
For nicer looking, we have embed the video window into the main dialog window. Current play position is synchronized with progress bar, and displayed as text in left to movie duration.

Points of Interest

The first goal of this project is prefer for preview and take snapshot, so it's named so. If you press Ctrl+Print Screen key when it playing, you'll notice that the video can be paste into mspaint. While Windows Media Player(WMP) can't do this. For WMP use video renderer in overlay mode.

History

Initial release

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)