Jump to content

mciSendString... .wav plays fine but .mid refuses to play, mciExecute works properly w/ both .wav and .mid...HELP!


 Share

Recommended Posts

So, here is some sample code Im messin around with and I cant get mciSendString to work at all w/ midi files.

$song = FileGetShortName(@WindowsDir & "mediaonestop.mid")
mciSendString('open "' & $song & '" type sequencer alias one')
Sleep(2000)
mciSendString("play one" )
Sleep(7500)
mciSendString("stop one" )

Func mciSendString($str)

   $ret = DLLCall("winmm.dll","int","mciSendString","str",$str, "str", "" ,"int", 65534,"hwnd",0)
   If NOT @ERROR Then
        Return $ret[2]
   Else
        SetError(1)
        Return ""
   EndIf
EndFunc

I can change it to notify.wav and set type to waveaudio and it plays just fine.

I can use mciExecute on both types of media and they play fine....I dont understand =/

Also, how would I implement mciGetErrorString to this function?

I am completely new to coding.. =/

Thanks for your help!

Edited by GenTarkin
Link to comment
Share on other sites

Hi and Welcome to the forums!!

Also, how would I implement mciGetErrorString to this function?

Try doing a forum search for mciGetErrorString and you'll only get two results, one being this thread and the other a code example :D
Link to comment
Share on other sites

Thanks for the warm welcome =)

Yes I did see that other users example here:

I did something like this:

$song = FileGetShortName(@WindowsDir & "mediaonestop.mid")
mciSendString('open "' & $song & '" type sequencer alias one')
Sleep(2000)
mciSendString("play one" )
Sleep(7500)
mciSendString("stop one" )
Func mciSendString($str)
dim $nErr
   $ret = DLLCall("winmm.dll","int","mciSendString","str",$str, "str", "" ,"int", 65534,"hwnd",0)
   If $ret[0] <> 0 then
$eMsg = DllCall"winmm.dll","long", "mciGetErrorString", "int", $nErr, "str", "", "int", 180)    
MsgBox(8208, "Error", "MCI Error: " & $nErr& @CRLF & $eMsg)
   Else
        SetError(1)
        Return ""
   EndIf
EndFunc

And it didnt return a proper error message, it just said the command ran fine, even though it couldnt run fine when the filename was wrong =P (as a test)

So, Im stuck on how to properly catch the errors =/

Edited by GenTarkin
Link to comment
Share on other sites

This works for me ...

Local $song = FileGetShortName(@WindowsDir & 'mediaonestop.mid')

mciSendString('open "' & $song & '" type sequencer alia one'); <--This will throw an error
mciSendString('open "' & $song & '" type sequencer alias one'); <--This won't

mciSendString('play one')
Sleep(7500)
mciSendString('stop one')

Func mciSendString($string)
    Local $mciMsg = DllCall('winmm.dll', 'long', 'mciSendStringA', 'str', $string, 'str', '', 'int', 180, 'ptr', 0)
    If @error Then Return SetError(@error, 0, -1)
    If $mciMsg[0] <> 0 Then
        Local $eMsg = DllCall('winmm.dll', 'long', 'mciGetErrorStringA', 'int', $mciMsg[0], 'str', '', 'int', 180)
        If @error Then Return SetError(@error, 0, -2)
        MsgBox(8208, "Error", 'MCI Error: ' & $mciMsg[0] & @CRLF & $eMsg[2])
        Return SetError(-3, 0, 0)
    EndIf
    Return SetError(0, 0, $mciMsg[2])
EndFunc

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...