GenTarkin Posted November 11, 2011 Posted November 11, 2011 (edited) 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 November 11, 2011 by GenTarkin
GenTarkin Posted November 11, 2011 Author Posted November 11, 2011 Hrm, seems I cant edit the post anymore, anyways, nevermind me...it works just fine, the PC I was on is jacked up. Anyways, can someone still point out how to impliment mciGetErrorString into my script? Thanks
AdmiralAlkex Posted November 11, 2011 Posted November 11, 2011 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 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
GenTarkin Posted November 11, 2011 Author Posted November 11, 2011 (edited) 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 EndFuncAnd 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 November 11, 2011 by GenTarkin
ripdad Posted November 11, 2011 Posted November 11, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now