|
-
Oct 5th, 2009, 09:19 AM
#1
Thread Starter
New Member
[RESOLVED] mp3 file/s
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
-
Oct 5th, 2009, 10:27 AM
#2
Re: mp3 file/s
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
-
Oct 5th, 2009, 01:20 PM
#3
Thread Starter
New Member
Re: mp3 file/s
i did that to browse but it gives an error after i click the mp3
-
Oct 5th, 2009, 09:44 PM
#4
Re: mp3 file/s
let me see ur code, and which line gives u error?
-
Oct 5th, 2009, 11:10 PM
#5
Thread Starter
New Member
Re: mp3 file/s
it works now, i just need the play button.
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
the only thing i need help now is how to select multiple files.
-
Oct 6th, 2009, 12:49 AM
#6
-
Oct 6th, 2009, 01:45 AM
#7
Thread Starter
New Member
Re: mp3 file/s
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
-
Oct 6th, 2009, 09:17 AM
#8
Re: mp3 file/s
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.
-
Oct 6th, 2009, 09:22 AM
#9
Thread Starter
New Member
Re: mp3 file/s
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.
-
Oct 6th, 2009, 09:31 AM
#10
Re: mp3 file/s
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?
-
Oct 6th, 2009, 11:58 AM
#11
Thread Starter
New Member
Re: mp3 file/s
this is the code i have for my online radio. this works well...
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
this is the second code i have to search an mp3 file on my pc to play. it works too, alone.
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
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.
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.
-
Oct 6th, 2009, 12:22 PM
#12
Re: mp3 file/s
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.
-
Oct 6th, 2009, 01:19 PM
#13
Thread Starter
New Member
Re: mp3 file/s
i am very sorry. i am too careless. i hope to learn more from these mistakes. thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|