Using the Features of Video Files

In the previous example, we used an audio file as our "test" to show how simple it was to load and play the content. What if we wanted to do the same thing with the video file "butterfly.mpg" instead? Simple enough; just use the following:

 Video someVideo = new Video("butterfly.mpg", true); 

If you ran code similar to this in your application, the very first thing you would notice is that the video plays in an entirely new window. While this may be adequate for you, what if you didn't want that? What if you already had a window where you wanted to display your movie? Of course, this is quite simple to do; however, it requires an extra couple lines. First, you will want to skip the auto play feature. Instead, use code like this:

 Video someVideo = new Video("butterfly.mpg"); someVideo.Owner = this; someVideo.Play(); 

The default option is not to auto-play the data, so we use the constructor that takes a single argument. We then set the owner of the video file, which can be any Windows Forms control. For example, it could be your main form itself, or a picture box that is a child of your form. Finally, we play the video. Notice now that the video is played inside the window you specified in the owner property?

You can also control the audio of a video (if it contains audio data) directly from the video object. You will notice that the video object has a property "Audio" which will return the Audio object associated with this video. You may use this just like you would any other audio object.



Managed DirectX 9 Graphics and Game Programming, Kick Start
Managed DirectX 9 Kick Start: Graphics and Game Programming
ISBN: B003D7JUW6
EAN: N/A
Year: 2002
Pages: 180
Authors: Tom Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net