rrTea wrote: ↑Sat Sep 14, 2019 6:34 amDo I always have to refer to a particular file name in order to stop it or is there a way to just issue a command "Stop current playing track"?
You can assign a alias ... which requires the file to be opened & closed ( instead of just play & stop ). It's pretty straight-forward though, here's a modified Sunset.zgeproj example.
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExternalLibrary ModuleName="Winmm.dll">
<Source>
<![CDATA[//
int mciSendStringA(string lpszCommand, xptr lpszReturnString, int cchReturn, int hwndCallback){}]]>
</Source>
</ZExternalLibrary>
<ZExpression>
<Expression>
<![CDATA[//
mciSendStringA("open Sunset.mp3 alias BGM", null, 0, 0);
mciSendStringA("play BGM", null, 0, 0);]]>
</Expression>
</ZExpression>
</OnLoaded>
<OnUpdate>
<KeyPress Keys="{" RepeatDelay="0.5">
<OnPressed>
<ZExpression>
<Expression>
<![CDATA[//
if(Pause)
{
mciSendStringA("play BGM", null, 0, 0);
}
else
{
mciSendStringA("stop BGM", null, 0, 0);
}
//
Pause = !Pause;]]>
</Expression>
</ZExpression>
</OnPressed>
</KeyPress>
</OnUpdate>
<OnClose>
<ZExpression>
<Expression>
<![CDATA[//
mciSendStringA("close BGM", null, 0, 0);]]>
</Expression>
</ZExpression>
</OnClose>
<Content>
<Variable Name="Pause" Type="4"/>
</Content>
</ZApplication>
Press left-mouse-button to pause & resume the track ( this is just to illustrate how the play & stop commands work in this situation ).
K