Results 1 to 4 of 4

Thread: My Midi file only plays in certain folders ! ? !

  1. #1

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526
    Now this seems really strange to me, but maybe one of you out there will know what the reason for this is.

    I've copied some code to get a midi file playing when my splash screen loads. I wanted to use a midi file I had put in the subfolder of c:\Program Files where the rest of my project resides. The thing just would not play so just as I was about to give up on having music with my splash screen, I tried copying the file to the desktop, switched the file path to the desktop file and voila! I had sound!!! I really don't understand how a midi file could work off the desktop but not in the same folder that the rest of my project resides.

    I don't want people to install this program and have a midi file added to their desktop, so I tried stashing it in the \Windows\Media and it works from there, too. I know, if it ain't broke, don't fix it, but I'm totally perplexed as to why it seems I can only get my midi to play when the file is in a subfolder of \Windows.

    Does any of this sound familiar to anyone?

    If it helps, here's the code that relates to midi:

    In the main module:

    Code:
    Option Explicit
    
    Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
      (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
      ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    In the splash screen general:

    Code:
    Public Sub sndPlayM(Filename As String)
        Call mciSendString("Open " & Filename & " Alias MM", 0, 0, 0)
        Call mciSendString("Play MM", 0, 0, 0)
    End Sub
    The splash screen form load:

    Code:
    Private Sub Form_Load()
    sndPlayM "C:\Windows\Media\Hall.mid"
    It works like this, but why the heck wouldn't it work when I had sndPlayM pointing to "C:\Program Files\Pest\Hall.mid"?????



    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Try calling the function with
    Code:
    sndPlayM chr(34) & "C:\Program Files\Pest\Hall.mid" & chr(34)
    The path contains a space, so that may be the problem.

    //Anders

  3. #3

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526

    Like magic!

    Wow, I have no idea why that worked, but it did! Not that I doubted you, but I really didn't think adding those chr$(34) was going to work. Well, I guess that means I did doubt you, but I was very happily surprised when my little tune came thumping through the speakers!

    The "Program Files" part of the path contains a space, but why does that make it necessary to add the chr$(34)'s to the beginning and the end of the file's path name?


    Thanks a bunch!

    [Edited by mikeycorn on 07-18-2000 at 12:43 AM]
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  4. #4
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    I'm not sure why it's neccesary, but it's the same thing when you make a link in explorer. If there is a space in the path or filename, it adds the " thingies. I would imagine that if you tried to execute a program via the run option for example, anything after the space could be considered a parameter to whaterever is before it... if you get what I mean.

    //Anders
    Reality is what you make up when you can't handle your fantasies.

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