Go Back   CodeCall Programming Forum > Software Development > Tutorials > CSharp Tutorials
Register Blogs Search Today's Posts Mark Forums Read

CSharp Tutorials Tutorials for C#

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-02-2009, 11:40 AM
ArekBulski's Avatar
Guru
 
Join Date: Mar 2009
Posts: 1,373
ArekBulski is just really niceArekBulski is just really niceArekBulski is just really niceArekBulski is just really niceArekBulski is just really nice
Tutorial: Playing video files with Managed DirectX

Welcome all! I wrote earlier a tutorial about playing audio files using mciSendString method. While it is a reasonable solution, I really prefer to use Managed DirectX. It gives much more control over what is happening. And besides, no crazy P/Invoke signatures are required. Therefore I decided to make a tutorial about it too, and let you be the judge. Enjoy reading.

Playing video with Microsoft.DirectX.AudioVideoPlayback namespace

Before you read further take this warning. If you are using Managed DirectX then not every computer will be able to run your program right away. The program will require both .NET Framework and DirectX installed. The problem arises when I add that DirectX has to be installed after .NET Framework, not before it. This is because it will also install Managed DirectX assemblies which are now among dependencies.

First thing to do is to add a reference. Open Solution Explorer and add the dependency. Then you are also going to need the same namespace. Just look at the screenshots below.

tutorial-playing-video-files-managed-directx-adding-reference.jpg tutorial-playing-video-files-managed-directx-adding-namespace.jpg

Playing video in control mode

This code starts playing the video in a Panel that I put into the form. I did not make an open dialog, though. I think just a Textbox will do.

Code:
Video video = new Video(FilenameTextbox.Text);
video.Owner = panel1;
video.Play();
tutorial-playing-video-files-managed-directx-three-modes-2-.jpg.jpg
Views:	74
Size:	62.3 KB
ID:	2063

Playing video in external window mode

This code starts playing in an external window. If you close that window then audio will still be playing. To stop playing there is the Video.Stop method.

Code:
Video video = new Video(FilenameTextbox.Text);
video.Play();
tutorial-playing-video-files-managed-directx-three-modes-3-.jpg.jpg
Views:	58
Size:	179.0 KB
ID:	2064

Playing video in fullscreen mode

The last piece of code will play in fullscreen mode. Again, pressing Alt+F4 will close the video but audio will go on.

Code:
Video video = new Video(FilenameTextbox.Text);
video.Fullscreen = true;
video.Play();
tutorial-playing-video-files-managed-directx-three-modes.jpg

Author thanks you for comments

I hope you enjoyed reading my tutorial. If it was helpful or useful then even more so. Feel free to post a comment or drop me some +rep. I thank you in advance.
Attached Files
File Type: zip DirectX AudioVideoPlayback solution.zip (13.9 KB, 122 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-02-2009, 01:48 PM
Jordan's Avatar
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 24,556
Jordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to all
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Re: Tutorial: Playing video files with Managed DirectX

Nicely done, Arek. +rep!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-02-2009, 05:04 PM
WingedPanther's Avatar
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 11,435
WingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud of
Re: Tutorial: Playing video files with Managed DirectX

Interesting. It sucks about the dependency order, though. +rep
__________________
CodeCall Blog | CodeCall Wiki | Shareware
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-14-2010, 11:07 PM
LuiDaHottest's Avatar
Newbie
 
Join Date: Jan 2010
Age: 19
Posts: 18
LuiDaHottest is an unknown quantity at this point
Re: Tutorial: Playing video files with Managed DirectX

finaly
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-22-2010, 03:59 AM
gokuajmes's Avatar
Newbie
 
Join Date: Jan 2010
Location: India
Age: 22
Posts: 12
gokuajmes is an unknown quantity at this point
Re: Tutorial: Playing video files with Managed DirectX

very nice . Good to know people have a lot of knowledge
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Playing MP3 files with C# ArekBulski CSharp Tutorials 10 01-22-2010 04:01 AM
Some Basic Linux Commands, For Beginners... Onur Linux Tutorials, Guides and Tips 5 10-12-2009 03:07 AM
DirectX Video Texture lore7460 Visual Basic Programming 5 05-28-2008 03:57 PM


All times are GMT -5. The time now is 09:52 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0