Lesson 22: Creating Multimedia Applications-Part IV:

A Multimedia Player

Custom Search

<Previous Lesson> <<Home>> < Next Lesson>

In lesson 20, we have created an audio player. Now, by making more modifications, you can transform the audio player into a multimedia player. This player will be able to search for all types of video files and audio files in your drives and play them. In this project, you will need to insert a ComboBox, a DriveListBox, a DirListBox, a TextBox ,a FileListBox  and a PictureBox into your form.

 

We Shall briefly explain the function of each of the above controls.

  • ComboBox- to display and enable selection of different type of files.

  • DriveListBox- to display different drives available on your PC.

  • DirListBox - To display the directories in your drives

  • TextBox - To display selected files

  • FileListBox- To display files that are available

  • PictureBox- To play the video files

 

 

Besides, you must also insert the Microsoft Multimedia Control(MMControl) into your form , you may make it visible or invisible. In our program, we choose to make it invisible so that we can use the command buttons created to control the player.In order to search for a multimedia file and play it with the multimedia player, the user needs to carry out the following steps:

Step 1: Decide the type of files he or she wants to play.

Step2: Select the drive that might contains the relevant multimedia files.

Step 3: Look into directories and subdirectories for the files specified in step1. The files should be displayed in the  FileListBox.

Step 4:  Select the files from the FileListBox and clicks the Play button.

Step 5: Click on the Stop button to stop playing and Exit button to end the application.

  

The Interface

 

The Code


Private Sub Form_Load()

'To fix the player size
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
Combo1.Text = "*.wav"
Combo1.AddItem "*.wav"
Combo1.AddItem "*.mid"
Combo1.AddItem "*.avi;*.mpg"
Combo1.AddItem "All files"


End Sub


Private Sub Combo1_Change()

        'To select types of media files

If ListIndex = 0 Then
File1.Pattern = ("*.wav")
ElseIf ListIndex = 1 Then
File1.Pattern = ("*.mid")
ElseIf ListIndex = 2 Then
File1.Pattern = ("*.avi;*.mpg")
Else
Fiel1.Pattern = ("*.*")
End If

End Sub

 

Private Sub Dir1_Change()

      'To search the directories or folders for the media files

File1.Path = Dir1.Path
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.wav")
ElseIf Combo1.ListIndex = 1 Then
File1.Pattern = ("*.mid")
ElseIf Combo1.ListIndex = 2 Then
File1.Pattern = ("*.avi;*.mpg")
Else
File1.Pattern = ("*.*")
End If

End Sub

Private Sub Drive1_Change()

'To Change Drives

Dir1.Path = Drive1.Drive

End Sub


Private Sub File1_Click()

'To load the selected file

If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.wav")
ElseIf Combo1.ListIndex = 1 Then
File1.Pattern = ("*.mid")
ElseIf Combo1.ListIndex = 2 Then
File1.Pattern = ("*.avi;*.mpg")
Else
File1.Pattern = ("*.*")
End If

If Right(File1.Path, 1) <> "\" Then
filenam = File1.Path + "\" + File1.FileName
Else
filenam = File1.Path + File1.FileName
End If
Text1.Text = filenam

End Sub

Private Sub play_Click()

MMPlayer.FileName = Text1.Text
MMPlayer.Command = "Open"
MMPlayer.Command = "Play"
MMPlayer.hWndDisplay = videoscreen.hWnd

End Sub


Private Sub stop_Click()

If MMPlayer.Mode = 524 Then Exit Sub
If MMPlayer.Mode <> 525 Then
MMPlayer.Wait = True
MMPlayer.Command = "Stop"
End If
MMPlayer.Wait = True
MMPlayer.Command = "Close"

End Sub

 

 

Bookmark and Share

<Previous Lesson> <<Home>> < Next Lesson>

Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved |Contact: admin@vbtutor.net

[Privacy Policy]