how do i open an mp3 file or folders with mp3 on my pc with just one command button in vb6. i already have wmplayer on the form. ty
Printable View
how do i open an mp3 file or folders with mp3 on my pc with just one command button in vb6. i already have wmplayer on the form. ty
do u mean to browse mp3 files? if yes u can use commondialog control to browse, hope u got it, if doubt feel free to ask
i did that to browse but it gives an error after i click the mp3
let me see ur code, and which line gives u error?
it works now, i just need the play button.
the only thing i need help now is how to select multiple files.Code:Option Explicit
Dim nome As String
Private Sub Command1_Click()
With CommonDialog1
.DialogTitle = "Select file"
.Filter = "Mp3 file (*.mp3) |*.mp3| Mp3 file (*.mp3) |*.mp3|"
.ShowOpen
nome = .FileName
End With
End Sub
Private Sub Command2_Click()
WindowsMediaPlayer1.URL = nome
End Sub
some sample code here
http://www.freevbcode.com/ShowCode.asp?ID=2771
thank you again. everything works, alone,as it is. but now i am trying to paste the code to an existing online radio station project i already have, and its giving an error. the online radio still works, but when i open a file on my pc and hit play, i get:
runtime error '424'
object required
then, WindowsMediaPlayer1.URL = mymusic is highligted in yellow
Private Sub Command2_Click()
WindowsMediaPlayer1.URL = mymusic
End Sub
Have you added the WindowsMediaPlayer control to your form? If not, press Ctrl+T and add it. If not done already, add OPTION EXPLICIT to the top of your forms/modules.
yes i have the WindowsMediaPlayer control. in fact when i select an online radio station, it works. but when i open an mp3 file, i can browse and select a file but the error on my previous post comes when i click my play button.
i also have OPTION EXPLICIT. thanks.
I assume myMusic is a string variable. And the .URL property of the WMP control is a string. To receive that error, VB is saying that it doesn't know what the WIndowsMediaPlayer1 is. These types of errors are usually caused by typo's in the control's name or referencing a control that is actually on another form, or indexing problems (i.e., WindowsMediaControl1(0) ).
If the above is not the case, click on the U in .URL so the cursor is between the dot and the letter U. Press Ctrl+J, do you get a drop down list?
this is the code i have for my online radio. this works well...
this is the second code i have to search an mp3 file on my pc to play. it works too, alone.Code:Private Sub List1_Click()
urlplay
End Sub
Private Sub urlplay()
rr = List1.List(List1.ListIndex)
lbl.Caption = "Opening " + rr
Select Case rr
Case "BBC World Service (UK)"
MediaPlayer1.URL = "http://www.bbc.co.uk/worldservice/meta/tx/nb/live/www15.asx"
Case "BBC 5 Live (UK)"
MediaPlayer1.URL = "http://www.bbc.co.uk/radio/listen/live/r5l.asx"
Case Else
MsgBox "Not A Valid Link", vbCritical
End Select
End Sub
Private Sub MediaPlayer1_OpenStateChange(ByVal NewState As Long)
If NewState = 13 Then
lbl.Caption = "Connected to " + List1.List(List1.ListIndex)
End If
End Sub
i want to insert the second code at the end of my first code (the online radio) so that i can also play an mp3 if i want to, instead of the radio.Code:Option Explicit
Dim mymusic As String
Private Sub Command1_Click()
With CommonDialog1
.DialogTitle = "Select file"
.Filter = "Mp3 file (*.mp3) |*.mp3| Mp3 file (*.mp3) |*.mp3|"
.ShowOpen
mymusic = .FileName
End With
End Sub
Private Sub Command2_Click()
WindowsMediaPlayer1.URL = mymusic
End Sub
when i include the Option Explicit from the second code, my online radio will not work, nor the mp3 play button. if i remove it, it will work but not the mp3 play.
As I stated earlier - typo. Your WMP control is not named WindowsMediaPlayer1 is it? Double check and you should be able to fix the problem.
i am very sorry. i am too careless. i hope to learn more from these mistakes. thank you.:)