Author |
Message |
molten_rock01
|
Posted: Thu Jun 02, 2005 3:43 pm Post subject: Playing .mp3 music |
|
|
Hi. I'm doing a project for school and would like to add additional features to one of my forms. This form is the first form a user sees (it's like a Welcome form). What I've done is that I've downloaded a bunch of mp3 songs from the internet. The only problem is, I don't know what to do to so that when a user runs the form, the music plays in the background. Could you please provide me with a simple tip, which is easy to understand? Thank you. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
McKenzie
|
Posted: Fri Jun 03, 2005 12:03 am Post subject: (No subject) |
|
|
There are a number of ways to do this. The easiest way is to right click at the bottom of the toolbox choose Components.... Add the Windows Media Player Control. Set the FileName to the MP3 that you want and set visible to false. If you want it to loop look under (custom) at the top of the properties list. |
|
|
|
|
|
betaflye
|
Posted: Fri Jun 03, 2005 1:37 pm Post subject: (No subject) |
|
|
Easiest way to do this in my opinion is with the Microsoft Multimedia Control 6.0, just add the mci32.ocx component into your form.
Here's code for a looping background song, adapt to your situation, make the control's visible property to false.
Private Sub Form_Load()
MMControl1.FileName = "C:\Song.mp3"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End Sub
Private Sub MMControl1_Done(NotifyCode As Integer)
MMControl1.Command "Prev"
MMControl1.Command "Play"
End Sub |
|
|
|
|
|
khanjan_a2k
|
Posted: Wed Nov 30, 2005 9:08 pm Post subject: (No subject) |
|
|
I tried to use the methods that both of you guys posted. But I had trouble. If you do not mind, could you please explain a little bit more so that i can understand. I am new to visual basic. I understand most of it, but i have touble occasionally.
Thanx |
|
|
|
|
|
kidz14
|
Posted: Thu Dec 15, 2005 7:04 pm Post subject: (No subject) |
|
|
well this is how it works you go iver to your tool bar right click on it then Choose Items... there's a .net framework componets tab and a COM Components tab select the COM Components tab then look for the windows media player control (wmp.dll) then make sure the box is checked once it's check select okay and it will add it to the toolbox in the where you had an object selected from last so lets say you had a lable selected it will put the control in the common control section of you toolbox now select the control from the tool box and put it on your form. then as "McKenzie" said you can set the controls visable to false then you can put a button on ur form and lets say the windows media player control is named wmp and the button name is Button1 then you could do something like this:
code: | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim opendlg As New OpenFileDialog
opendlg.InitialDirectory = Environment.SpecialFolder.Desktop
opendlg.Filter = "All Files(*.*)|*.*|Mp3 Files(*.mp3)|*.mp3"
opendlg.FilterIndex = 2
opendlg.RestoreDirectory = True
If opendlg.ShowDialog = Windows.Forms.DialogResult.OK Then
wmp.URL = opendlg.FileName
End If
End Sub |
|
|
|
|
|
|
|