Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems looping a MIDI file with mcisendstring.
#1
The following code, which is a modified version of the MCI Helper that comes with FB v.11b, was my attempt to make a MIDI file loop. It doesn't work:
Code:
' Modified MCI helper.
' By Vance Velez.


'  *** Function Declarations. ***

declare function PlayMidi(filename as string, musicID as string) as integer
declare function CheckMidi(musicID as string) as integer
declare function StopMidi( ) as integer

'$include: 'win\mmsystem.bi'

'  *** Initialize MIDI. ***
mciSendString("open sequencer",byval NULL,0,0)

'  *** Play MIDI. ***
PlayMidi("c:\vance\music\mario.mid", musicID$)

do
   a$=inkey$  
   CheckMidi(musicID$)
   if a$="a" then mciSendString("play mymidi from 0",byval NULL,0,0)
loop until a$=" "

'  *** Close MIDI. ***
mciSendString("close sequencer",byval NULL,0,0)

end

'  *** Midi Routines. ***

function PlayMidi(filename as string, musicID as string) as integer
    
   if(mciSendString("open "+filename+" alias mymidi",byval NULL,0,0)<>0) then
        winmmPlayMidi = 0
        exit function
    end if  
  
   musicID="A"  
   mciSendString("status mymidi mode", musicID, 5, 0)      
   PlayMidi=mciSendString("play mymidi",byval NULL,0,0) = 0    
    
end function

function CheckMidi(musicID as string) as integer

   retStr$="A"
   mciSendString("status mymidi mode",retStr$,5,0)      
   ?"RET: ";retStr$;" ID: ";musicID;  
   if retStr$=musicID then
      ?" ACTIVE"      
      PlayMidi("c:\vance\music\mario.mid", musicID)
      mciSendString("play mymidi from 0",byval NULL,0,0)
   else
      ?
   end if
   CheckMidi=0  
end function

function StopMidi() as integer    
    mciSendString("stop mymidi",byval NULL,0,0)
    StopMidi=mciSendString("close mymidi",byval NULL,0,0)=0    
end function

' *** End of Code. ***

Instead, it plays through the MIDI once and goes silent after that. What am I doing wrong? Sad
eese Witherspoon is so pretty
Her and Ryan Philippe make such a cute couple I think
My dream is that QB and all OSes share such a wonderful relationship
V Planet! QB Magazine
http://www.vplanetmag.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)