This is a VB6 Windows media player that can play all kinds of media files such as wav, midi, mp3, mpeg video, avi video and more. When you launch the program, you can select media files of different types from different sources such as your hard drives, CD and even the URL of a webpage . After you have selected a particular file, you can play it using the customized button or you can use the buttons of the Windows Media Player
In this program, you need to insert the Windows Media Player Control. This control is not available in the default VB6 IDE, you have to press CTRl+T keys to bring up the components dialog, and check the Windows Media Player then click OK, as shown in Figure 1. In addition, you need to insert Microsoft Common Dialog Control 6.0 into the form. This control is also not available in the default IDE, press CTRL+T to bring up the components windows and check on this control, as shown in Figure 2.
Now you are ready to design the player's interface. First, drag the Windows Media Player control into the form and reside it to a certain size. Set its fullScreen property to false. Next, insert Microsoft Common Dialog Control 6.0 in the form and then insert five command buttons in the form. Change the caption of first button to Open, second one to Play, third one to Close, fourth one to Exit and the last one to Full Screen. Finally, insert a text box for the purpose to display the URL of the selected media file. The design would look like the one shown in Figure 3.
For the Open command button, change its name to cmdOpen and enter the following codes:
Private Sub cmdOpen_Click()
Me.CommonDialog1.Filter = "WAV Files (*.wav)|*.wav|" & "MP3 Files (*.mp3)|*.mp3|" & "MP4 Files (*.mp4)|*.mp4|" & "Video Files (*.avi)|*.avi|" &"MPEG Files (*.mpg)|*.mpg|" CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
For the Play button, change its name to cmdPlay and enter the following codes:
Private Sub cmdPlay_Click()
WindowsMediaPlayer1.URL = Text1.Text
For the Stop button, change its name to cmdStop and enter the following codes:
Private Sub cmdStop_Click()
For the Full Screen button, change its name to cmdMax and enter the following codes:
Private Sub cmdMax_Click()
WindowsMediaPlayer1.fullScreen = True
Now run the program and click on the Open button. A dialog box will appear that allows you to choose your media files, as shown in Figure 4. After selected the file and click on the Play button, it will play the selected media file as shown in Figure 5.