Results 1 to 13 of 13

Thread: [RESOLVED] mp3 file/s

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    Resolved [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

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    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
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    Re: mp3 file/s

    i did that to browse but it gives an error after i click the mp3

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: mp3 file/s

    let me see ur code, and which line gives u error?
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    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.

  6. #6
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: mp3 file/s

    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    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

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    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.

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    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.

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    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
  •  



Click Here to Expand Forum to Full Width