- Fixed an issue that audio commands fail in some cases.

Following cases are now available:

ButtonCommand=PLAY #SKINSPATH#Beeper\Sounds\beep.wav
ButtonCommand=PLAY "#SKINSPATH#Beeper\Sounds\beep.wav"
ButtonCommand=!execute [PLAY #SKINSPATH#Beeper\Sounds\beep.wav]
ButtonCommand=!execute [PLAY "#SKINSPATH#Beeper\Sounds\beep.wav"]
This commit is contained in:
spx
2010-09-02 16:03:15 +00:00
parent e29b2a2d4b
commit 7f2c47a956
4 changed files with 37 additions and 20 deletions

View File

@ -2653,10 +2653,31 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
if (!strCommand.empty())
{
// Check for build-ins
if (wcsncmp(L"PLAY ", strCommand.c_str(), 5) == 0)
// Check for built-ins
if (wcsnicmp(L"PLAY ", strCommand.c_str(), 5) == 0 ||
wcsnicmp(L"PLAYLOOP ", strCommand.c_str(), 9) == 0)
{
BOOL ret = PlaySound(strCommand.c_str() + 5, NULL, SND_FILENAME | SND_ASYNC);
// Strip built-in command
size_t pos = strCommand.find(L' ');
strCommand.erase(0, pos + 1);
if (!strCommand.empty())
{
DWORD flags = SND_FILENAME | SND_ASYNC;
if (pos == 8) // PLAYLOOP
{
flags |= SND_LOOP | SND_NODEFAULT;
}
// Strip the quotes
std::wstring::size_type len = strCommand.length();
if (len >= 2 && strCommand[0] == L'\"' && strCommand[len - 1] == L'\"')
{
strCommand.swap(strCommand.substr(1, len - 2));
}
PlaySound(strCommand.c_str(), NULL, flags);
}
return;
}
else if (wcsncmp(L"PLAYSTOP", strCommand.c_str(), 8) == 0)
@ -2664,11 +2685,6 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
PlaySound(NULL, NULL, SND_PURGE);
return;
}
else if (wcsncmp(L"PLAYLOOP ", strCommand.c_str(), 9) == 0)
{
PlaySound(strCommand.c_str() + 9, NULL, SND_ASYNC | SND_FILENAME | SND_LOOP | SND_NODEFAULT);
return;
}
// Run the command
if(strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep())