Video
Up
Adding video isn't particularly difficult, and it's a whole lot of fun. The basic steps are:
bulletmake a video file or find one on the internet
bulletsave the video file into the same folder as your project
bulletadd a Windows Media Player control to your project
bulletwrite one line of code to tell the media player control the location and name of the movie file

Always remember that video files are often very large - high quality digital video (DV standard) consumes 3.2MB for every second of video! To keep the file size under control, videos should have small dimensions and a low frame rate (number of frames per second). The low frame rate can makes the video seem rather jerky.

The details:

Make a video file or find one on the internet

The Media Player control is compatible with various video formats such as MOV, MPG and AVI, but it is not compatible with REAL video. Some digital still cameras can also film moving video and transfer it to a computer in one of the above formats.

Some sites such as www.jurassicpunk.com have large selections of video files for download. Remember that video files are often several MB in size and may take a long time to download unless you have an ADSL connection. In my experience, many of these video files may display correctly in the browser but may fail within the media player control because they are not correctly formatted - if one video file does not work properly then try another.

Save the video file into the same folder as your project

This allows us to write simple code to tell the media player control where to find the video file and what the name of the file is.

Add a Windows Media Player control to your project

The media player tool is not built in to the toolbox but can be added by choosing Components from the Project menu. Put a check in the box next to Windows Media Player then click OK. Double-click the new tool to add an instance of the media player control to your form. It would be a good idea to immediately rename the new control MPL1, and in the code below I will assume that you have done this.

Write one line of code to tell the media player control the location and name of the movie file

You could put this in the Form_Load procedure:

MP1.filename = app.path & "\mymovie.mov"

(replace mymovie.mov with the name of your movie file). App.path tells the control to look for the movie in the same folder when the project is saved. No special code or command button is needed to play the movie since the media player control has its own set of icons for playing, pausing and stopping movies. In fact the movie will play automatically unless the control's autoplay property is turned off. If you MUST control the player using code just use the methods:

MPL1.play       and       MPL1.stop

You might also want to use the Media Player control if you want to play a MIDI music file or an MP3 sound file - the media player control is compatible with both. MIDI files are neat because they are not actually recorded sounds, they are more like musical scores - a set of instructions on how to play a piece of music. This makes them very compact, just a few K. You can download a sample MIDI file called missingyou.mid by right-clicking HERE and a sample mp3 file called bowling.mp3 HERE.

If you want to play a WAV sound it is possible to use the media player, but probably neater to use the methods described in the previous project, called Sound.

Previous Up Next