CodeItBetter Programming Another VB Programming Blog

How to use Windows Media Player to Play MP3 Files in your application

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'MultiMedia - How to use Windows Media Player to Play MP3 Files in your application

Option Explicit
 
'Requirements: You must have Windows Media Player installed on your system.

'1. Add Windows Media Player to your form. To do that, Goto Project -> Components ... then
'   select the Windows Media Player check box and hit OK. Now drag the Windows Media Player
'   Control to your form from Toolbox.
'2. If you do not want to show the media player to your user you can set the visible
'   Property to false.
'3. Add three command buttons to your form and Rename it to "Play", "Stop", "Pause/Resume".

Private Sub Command1_Click()
    'To Play the mp3 file
    'Replace the "C:\Songs\TestFile.mp3" below with the Mp3 file you want to play
    MediaPlayer1.Open "C:\Songs\TestFile.mp3"
End Sub
 
Private Sub Command2_Click()
    'To stop the current song
    MediaPlayer1.Stop
End Sub
 
Private Sub Command3_Click()
    'if PlayState is 2: the file is currently playing.
    'if PlayState is 1: the file is in pause mode.
    If MediaPlayer1.PlayState = 2 Then
        MediaPlayer1.Pause
    Else
        MediaPlayer1.Play
    End If
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.