Results 1 to 6 of 6

Thread: trouble playing a music file...

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    32

    trouble playing a music file...

    so a friend helped me out with this bit of code

    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Const SND_SYNC = &H0 ' play synchronously (default)
    Const SND_NODEFAULT = &H2

    Private Sub Image1_Click()
    Dim sound1 As Long
    sound1 = sndPlaySound("insert music file path here", SND_NODEFAULT)
    End Sub

    so it works when i enter a MP3 file of a guitar string...but when i try and put a MP3 music file in the pathname nothing happens...anyone have any idea what up?

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

    Re: trouble playing a music file...

    so, it played an MP3 file? That's news to me, I didn't know that API can play MP3s. Jump to the last 2 posts in this link and try using mciSendString instead. Adjust the posted code to suit your needs. You can also do a forum search for MP3 and get even more examples.
    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}

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    32

    Re: trouble playing a music file...

    alright the code seems simple enough, i'm just unsure what i'm supposed to pass Play_MM

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

    Re: trouble playing a music file...

    From that example? Nothing, just do as it says: "Play MM". MM is a string "name" given to that instance of mciSendString so that you can query later if needed, to see if it is still playing or other more advanced attributes. MM in that example is just a name, you can call it anything, like "MyMusicFile" for example, then change the call to: "Play MyMusicFile"
    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}

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    32

    Re: trouble playing a music file...

    ok i'm a real noob at programing(took a class last year in highschool but the second half we programed in c++) so from what i see, when i click the play button i call mciSendString....but i dont see where i tell it the path name of the file i want to play...

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

    Re: trouble playing a music file...

    If you are using that code, pass the full path & file name to the function.
    Example: Play_MM "C:\Guitar.mp3"

    P.S. I misunderstood the previous posting, I though you were refering to the "Play MM" in the mciSendString call, not the function. Sorry about that.
    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}

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