Build MP3 Player without WMP OCX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chokies12
    New Member
    • Mar 2008
    • 8

    Build MP3 Player without WMP OCX

    hello guys im new here..hope you can help make my first project in visual basic..i want to make a mp3 player in visual basic without using the WMP OCX.. i have started i downloaded a simple mp3 player without WMP OCX and use it as a reference but since it has no tutorial i have to see the codes 1by1 i cant play my project..here's my code..

    [code=vb]

    Private Sub CmdBrowse_Click ()
    On Error GoTo error

    With CDlg1
    'On Cancel do nothing
    .CancelError = True

    .DialogTitle = "Browse For MP3 Files"
    .Filter = "MP3 Files (*.mp3) |*.mp3; |Wave Files (*.wav) |*.wav; |Midi Files (*.mid) |*.mid"
    .ShowOpen
    'Handle no filename
    If Len(.FileName) = 0 Then Exit Sub

    txtFile.Text = .FileName
    CmdPlay.SetFocu s 'Press enter to play
    End With

    error: 'Do nothing
    End Sub

    Private Sub CmdPlay_Click()
    Play
    End Sub

    Private Sub TxtFile_Change( )
    Dim Ext As String
    'Check if there is a string in txtFile
    If txtFile <> "" Then
    'File extension is the last three letters
    Ext = LCase(Right(txt File, 4))
    'If extension is supported enable player buttons
    If Ext = ".mp3" Or Ext = ".wav" Or Ext = ".mid" Then
    CmdPlay.Enabled = True
    CmdPause.Enable d = True
    CmdStop.Enabled = True
    CmdRew.Enabled = True
    CmdFF.Enabled = True
    chkLoop.Value = 1
    End If
    Else
    'If no file name disable player buttons
    CmdPlay.Enabled = False
    CmdPause.Enable d = False
    CmdStop.Enabled = False
    CmdRew.Enabled = False
    CmdFF.Enabled = False
    chkLoop.Value = 2
    End If
    End Sub
    [/code]

    when i open i file i gives a error about thet command "Play" i think theres something wrong about it but in my reference player thats the only command in the CmdPlay button
    Last edited by debasisdas; Mar 11 '08, 01:13 PM. Reason: added code=vb tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    What is that Play in your code ?

    Comment

    • chokies12
      New Member
      • Mar 2008
      • 8

      #3
      oh your right "Play" Has no value..

      how do i declare a value for play?can you kindly help me im new in visual basic..

      Comment

      • VBWheaties
        New Member
        • Feb 2008
        • 145

        #4
        Originally posted by chokies12
        oh your right "Play" Has no value..

        how do i declare a value for play?can you kindly help me im new in visual basic..
        Whats this mp3 player that you downloaded and set a reference to? Need the name of it in order to understand its code.

        Comment

        • chokies12
          New Member
          • Mar 2008
          • 8

          #5
          i downloaded this at freevbcode.com "Pocket Player" here's the code im looking at it 1by1 so i can understand how it was made..

          Comment

          • chokies12
            New Member
            • Mar 2008
            • 8

            #6
            i cant seem to post the the pocket player code..it seems that its too long so there nothing that appears in my reply..

            DL link for the pocket player code

            Comment

            • chokies12
              New Member
              • Mar 2008
              • 8

              #7
              please help me with this project..how do i declare a function for play?

              Comment

              • chokies12
                New Member
                • Mar 2008
                • 8

                #8
                please help me need your answer about this

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  you need to have some patience. The people who respond here are volunteering their own time, and are located in various timezones around the world.

                  I'd have a look at the code now, but my work system blocks access when I try to open the link. :-(

                  Comment

                  • chokies12
                    New Member
                    • Mar 2008
                    • 8

                    #10
                    Originally posted by Killer42
                    you need to have some patience. The people who respond here are volunteering their own time, and are located in various timezones around the world.

                    I'd have a look at the code now, but my work system blocks access when I try to open the link. :-(
                    oh im sorry about my impatience..im having problem posting the code here since its too long..

                    Comment

                    • VBWheaties
                      New Member
                      • Feb 2008
                      • 145

                      #11
                      yep. my work also blocks. i wonder if we work at same place. :)

                      Comment

                      • Killer42
                        Recognized Expert Expert
                        • Oct 2006
                        • 8429

                        #12
                        Originally posted by VBWheaties
                        yep. my work also blocks. i wonder if we work at same place. :)
                        I don't think it's that rare.

                        Comment

                        • chokies12
                          New Member
                          • Mar 2008
                          • 8

                          #13
                          guys i think this the code value of "Play" i dont know which line is making it play..

                          Code:
                          Sub Play()
                          
                          Dim CurState As Long
                           'check player
                           If Not Player Is Nothing Then
                              'Get the state
                              Player.GetState x, CurState
                                
                              If CurState = 1 Then
                                PausePlay
                                Exit Sub
                              End If
                           End If
                           
                           StartPlay 'Start playing the file
                          
                          End Sub
                          Sub StartPlay()
                          
                          On Error GoTo error                   'Handle Error
                             'Set objects
                             Set Player = New FilgraphManager   'Player
                             Set PlayerPos = Player             'Position
                             Set PlayerAU = Player              'Volume
                          
                             Player.RenderFile txtFile.Text     'Load file
                             AdjustVolume                       'Set Volume
                             Player.Run                         'Run player
                             PlayerIsPlaying = True             'We are playing
                             playTimer.Enabled = True           'Start play timer
                             lblStatus.Caption = "Playing..."   'Status
                             cmdBrowse.Enabled = False          'No file open before stop
                             txtFile.Enabled = False            'No change
                             VolSlider.SetFocus                 'Remove focus from cmdPlay
                             i = 0                              'Animate icon
                             GetMP3Tags                         'Load mp3 file tags
                             Me.Caption = Me.Caption & " [" & txtInfo.Text & "]"
                          
                          Exit Sub
                          error:                                 'Handle error
                             StopPlay                            'Stop player
                             cmdBrowse.Enabled = True            'Enable file browser
                             txtFile.Enabled = True              'Enable file name text box
                             lblStatus.Caption = Err.Description 'Write error description to status label
                             
                          End Sub

                          Comment

                          • VBWheaties
                            New Member
                            • Feb 2008
                            • 145

                            #14
                            You have to set a reference to "Quartz.dll ".
                            And according to the article, the technology (DirectShow) has been deprecated or not supported anymore.
                            Heres the article:

                            Comment

                            • Killer42
                              Recognized Expert Expert
                              • Oct 2006
                              • 8429

                              #15
                              Originally posted by chokies12
                              guys i think this the code value of "Play" i dont know which line is making it play.
                              My money would be on line 28.

                              Comment

                              Working...