Results 1 to 4 of 4

Thread: How can I play music file MP3 in VB?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    61

    Post

    Dear Masters' VB

    Please help me, How can I play music file MP3 in VB?
    Many thanks for your help.

  2. #2
    Member
    Join Date
    Nov 1999
    Posts
    63

    Post

    There are 3 ways you could do it--each having a different level of complexity.

    1. Use the shell function to launch your MP3 with Window's mplayer or mplayer2.

    Code:
    Shell ("mplayer.exe /play C:\your.mp3", vbMinimizedNoFocus)
    2. Add the MS Multimedia control to a form.

    Code:
    MMControl1.Wait = True
    MMControl1.FileName = "C:\your.mp3"
    MMControl1.Command = "Open"
    3. Make direct use of the Window's multimedia API calls.

    Code:
    Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
    
    
    Private Sub Command1_Click()
        mciExecute ("play c:\your.mp3")
    End Sub

    Gerald M.


    [This message has been edited by Gerald (edited 12-15-1999).]

  3. #3
    New Member
    Join Date
    Nov 2005
    Posts
    5

    Re: How can I play music file MP3 in VB?

    hey,

    the third funsction does not work is there anything wrong with it or is it just my stupid machine.

  4. #4
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: How can I play music file MP3 in VB?

    mciExecute (a simplified version of mciSendString) will fail if the path to the file contains spaces (isn't in DOS 8.3 format). Use GetShortPathName to returns a valid path/file name.

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