Click here to Skip to main content
Click here to Skip to main content

C# Movie Player

By , 21 May 2007
 
Screenshot - zmovieplayer.jpg

Introduction

After I found that my previous movie player was broken by all the changes done to Vista, I started looking for a C# solution based on managed DirectX.

Everything I tried with the original Vista failed, until I downloaded the latest Microsoft DirectX 9L version from April 2007 that solved all my Vista problems.

Thus in order to use this code with Vista (no problem running it under XP), you must first download the latest DirectX SDK from here.

Then you will be able to use the Microsoft.DirectX.AudioVideoPlayback assembly.

Documentation

Once you have installed the full DirectX SDK, and assuming you have installed it with the default setup, you can find the documentation about the AudioVideoPlayback assembly in this folder:
C:\Program Files\Microsoft DirectX SDK (April 2007)\Documentation\DirectX9\directx9_m.chm.

Using the Player

zMoviePlayer is able to play: AVI, MPG, MPEG, WMV, DivX, Xvid (assuming that you have installed the right CODEC first).

While in "full screen" mode, move the mouse to the bottom to show/hide the "command panel".

To select a movie, use either the Menu to popup the common dialog file selector, or use Drag & Drop from the Explorer onto the zMoviePlayer form.

Using the Code

The main DirectX class of the player is named Video and it is very easy to use.
You can get all the details about it from the Visual Studio popup contextual menu (get definition).

Because I wanted to have a nice looking interface "a la WMP 11", I have added a few classes myself to perform the skinning of the player. They are:

  • SkinButton.cs - User control to create skinned button using one single 5-image bitmap matching each of the button states: normal, down, disabled, focused, hover.
    You can use either "standard" push button or shaped button with region.
  • SkinTrackbar.cs - User control to create a mouse only skinned track bar. The thumb tracker can have any size or shape based on a provided bitmap. The control orientation is based on the ratio between width and height, if width is larger than height, then horizontal else vertical. To help the user figure out the moving of the thumb track, the control uses different colors to show the current value. You can inverse ranging swapping min/max values.
  • SkinEngine.cs - This class is responsible for the drawing of the skinned controls.

Points of Interest

To get rid of the "loaderlock" exception message while running in the Visual Studio environment:
Use "Ctrl + Alt + E" to open the Exceptions dialog box, select "Managed Debugging Assistants" and uncheck "Loaderlock".

History

Updated on 05-22-2007 (version 1.04)

  • COMMAND line support (works also to drag movie file from Explorer onto the player's desktop icon if any)
  • PROCESS DETECTION: see IsAlreadyRunning()
  • ICONIC mode detection to restore original location (when the command line is being used)
  • AUDIO LEVEL saved between sessions
  • New label ShowTime (to see the current time while running in full screen mode)
  • Private WM_STRINGDATA message to play a new movie, using command line file name

Updated on 05-15-2007 (version 1.03)

  • This version saves the latest folder being used into the registry and retrieves it between sessions to ease movie selection (very handy when all the movies are stored into the same folder inside a dedicated sub-folder sorted by movie type).
  • HD movies (WMV HD movies do not work on Vista)
  • MUTE problem has been fixed (MUTE was ignored when playing a new movie even when ON)

See My Other C# Demos

http://www.zapsolution.com/winlift/ccorner.htm - Make sure to try the "carousel" demo!

Patrice Terrier
www.zapsolution.com

License

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

About the Author

zapsolution
Software Developer zapsolution
France France
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionIm getting a null exception when trying to load a video file . Why is that ?memberchocolade28 Nov '12 - 2:43 
AnswerRe: Im getting a null exception when trying to load a video file . Why is that ?memberMember 988500517 Mar '13 - 3:11 
GeneralMy vote of 5membermanoj kumar choubey26 Feb '12 - 20:00 
GeneralMy vote of 5memberrealbanda26 Oct '10 - 18:12 
GeneralRe: A little bugmemberMegaGigsLtd16 Oct '10 - 14:44 
GeneralRe: A little bugmemberSteph17x20 Jan '11 - 3:33 
GeneralRe: A little bugmemberneonyourself16 Feb '11 - 4:43 
GeneralRe: A little bugmemberzapsolution16 Feb '11 - 5:22 
GeneralRe: A little bugmembersandven29 Jun '12 - 13:21 
QuestionAutoclose the player at the end of the movie?memberJerry Jalenak16 Mar '10 - 5:47 
AnswerRe: Autoclose the player at the end of the movie?membersilversurfer023 Mar '10 - 17:38 
Generalshow black bars above and below the video for video of resolution 720*576memberiuril2 Mar '10 - 8:53 
GeneralUn-managed versionmemberzapsolution31 Jan '10 - 5:11 
Generalcapture imagememberchtoph13 Nov '09 - 19:38 
GeneralRe: capture imagememberzapsolution13 Nov '09 - 20:12 
GeneralRe: capture imagememberLEM38 Jun '10 - 11:17 
QuestionAudioVideoPlayback.dll [modified]memberKEL329 Sep '09 - 8:52 
AnswerRe: AudioVideoPlayback.dllmemberDiamonddrake5 Nov '09 - 14:54 
GeneralThanksmembero3yoon23 Apr '09 - 18:57 
GeneralGood workmemberDr.Luiji26 Dec '08 - 9:58 
Generalhelp 2.0 assembly...memberdeching28 Oct '08 - 22:14 
GeneralSOS !!! Can't Find Microsoft.DirectX.AudioVideoPlayback...HELP PLS!!!memberdebanjan.routh8 Oct '08 - 19:19 
GeneralSubtitles...memberyarns29 Sep '08 - 9:46 
GeneralRe: Subtitles...memberzapsolution29 Sep '08 - 11:12 
Question1080p?memberwuxing91325 Aug '08 - 0:28 
AnswerRe: 1080p?memberzapsolution25 Aug '08 - 3:05 
Generalpng filesmemberMAHorn22 Jul '08 - 7:01 
GeneralRe: png filesmemberzapsolution22 Jul '08 - 8:47 
GeneralRe: png filesmemberMAHorn23 Jul '08 - 6:36 
GeneralRe: png filesmemberzapsolution23 Jul '08 - 7:36 
GeneralOptimizationmemberRyan Velasco26 Mar '08 - 18:51 
AnswerRe: Optimization [modified]memberzapsolution27 Mar '08 - 1:23 
GeneralRe: OptimizationmemberRyan Velasco27 Mar '08 - 14:34 
GeneralRe: Optimizationmemberzapsolution28 Mar '08 - 3:05 
GeneralRe: OptimizationmemberRyan Velasco28 Mar '08 - 14:34 
GeneralEstablishing marks points in a videomemberxraziel17 Mar '08 - 7:21 
GeneralStreamingmemberdsanghera28 Nov '07 - 22:17 
QuestionGetting frame informationmemberYigal Agam2 Nov '07 - 5:07 
GeneralAudioVideoPlaybackmemberpastime_wang5 Sep '07 - 0:58 
GeneralRe:Hanging Player while resizing windowmemberRameshwerE13 Aug '07 - 22:08 
QuestionExceptionmemberkazim bhai18 Jul '07 - 3:46 
AnswerRe: Exceptionmemberzapsolution18 Jul '07 - 5:47 
GeneralIn dual monitors the video appear in the second monitor toomembervelezgallego6 Jun '07 - 10:54 
GeneralRe: In dual monitors the video appear in the second monitor toomemberahar083@cse.unsw.edu.au12 Jun '07 - 8:15 
QuestionCreating a Video splash screen - repeat?memberrreukema28 May '07 - 13:13 
AnswerRe: Creating a Video splash screen - repeat?memberzapsolution28 May '07 - 21:48 
Generalcontrol movie speedmembercekasp22 May '07 - 1:44 
GeneralRe: control movie speedmemberchris17522 May '07 - 1:46 
GeneralRe: control movie speedmemberzapsolution22 May '07 - 4:13 
GeneralRe: control movie speedmemberzapsolution22 May '07 - 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 22 May 2007
Article Copyright 2007 by zapsolution
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid