+ Reply to Thread
Results 1 to 6 of 6

Thread: Tutorial: Playing video files with Managed DirectX

  1. #1
    Guru ArekBulski is just really nice ArekBulski is just really nice ArekBulski is just really nice ArekBulski is just really nice ArekBulski is just really nice ArekBulski's Avatar
    Join Date
    Mar 2009
    Posts
    1,379

    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 with Managed DirectX-adding-reference.jpg Tutorial: Playing video files with 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 with Managed DirectX-three-modes-2-.jpg

    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 with Managed DirectX-three-modes-3-.jpg

    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 with 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.
    Bijgevoegde bestanden

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,750
    Blog Entries
    97

    Re: Tutorial: Playing video files with Managed DirectX

    Nicely done, Arek. +rep!

  3. #3
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    37
    Posts
    13,155
    Blog Entries
    59

    Re: Tutorial: Playing video files with Managed DirectX

    Interesting. It sucks about the dependency order, though. +rep
    CodeCall Blog | CodeCall Wiki
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #4
    Newbie LuiDaHottest is an unknown quantity at this point LuiDaHottest's Avatar
    Join Date
    Jan 2010
    Age
    20
    Posts
    18

    Re: Tutorial: Playing video files with Managed DirectX

    finaly

  5. #5
    Programming Expert gokuajmes will become famous soon enough gokuajmes will become famous soon enough gokuajmes's Avatar
    Join Date
    Jan 2010
    Location
    India
    Age
    22
    Posts
    377
    Blog Entries
    4

    Re: Tutorial: Playing video files with Managed DirectX

    very nice . Good to know people have a lot of knowledge

  6. #6
    Newbie almohands is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    3

    Re: Tutorial: Playing video files with Managed DirectX

    i have problem when make debug it,s take the DirecX dose not exsit
    but i have DirecX 11 and install it in may computer
    please help me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Tutorial: Playing MP3 files with C#
    By ArekBulski in forum CSharp Tutorials
    Replies: 17
    Last Post: 05-28-2010, 04:17 AM
  2. Some Basic Linux Commands, For Beginners...
    By Onur in forum Linux Tutorials, Guides and Tips
    Replies: 5
    Last Post: 10-11-2009, 11:07 PM
  3. DirectX Video Texture
    By lore7460 in forum Visual Basic Programming
    Replies: 5
    Last Post: 05-28-2008, 11:57 AM