Code: Select all
soundplay, Audio\What's the name of the wall that the Romans built to keep the Scots out of England.wav, wait
soundplay, Audio\What's the name of the wall.wav, wait
Code: Select all
soundplay, Audio\What's the name of the wall that the Romans built to keep the Scots out of England.wav, wait
soundplay, Audio\What's the name of the wall.wav, wait
Code: Select all
soundplay, Audio\What's the name of the wall that the Romans built to keep the Scots out of England a.wav, wait
Code: Select all
soundplay, Audio\What's the name of the wall that the Romans built to keep the Scots out of England ab.wav, wait
Code: Select all
q:: ;file get short-form path
vPath := A_ScriptFullPath
Loop, Files, % vPath, F
vPathShort := A_LoopFileShortPath
MsgBox, % vPathShort
return
Code: Select all
q:: ;play sound (handle longer filenames)
vPath := A_Desktop "\MyMp3.mp3"
Loop, Files, % vPath, F
vPathShort := A_LoopFileShortPath
MsgBox, % vPathShort
SoundPlay, % vPathShort
return
Code: Select all
q:: ;play sound (handle longer filenames)
vPath =
(Join
Audio\What's the name of the wall that the Romans built to keep the Scots out of England.
What's the name of the wall that the Romans built to keep the Scots out of England.wav
)
Loop, Files, % vPath, F
vPathShort := A_LoopFileShortPath
SoundPlay, % vPathShort
return
Code: Select all
ResultType Line::SoundPlay(LPTSTR aFilespec, bool aSleepUntilDone)
{
LPTSTR cp = omit_leading_whitespace(aFilespec);
if (*cp == '*')
return SetErrorLevelOrThrowBool(!MessageBeep(ATOU(cp + 1)));
// ATOU() returns 0xFFFFFFFF for -1, which is relied upon to support the -1 sound.
// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_play.asp
// for some documentation mciSendString() and related.
TCHAR buf[MAX_PATH * 2]; // Allow room for filename and commands.
mciSendString(_T("status ") SOUNDPLAY_ALIAS _T(" mode"), buf, _countof(buf), NULL);
if (*buf) // "playing" or "stopped" (so close it before trying to re-open with a new aFilespec).
mciSendString(_T("close ") SOUNDPLAY_ALIAS, NULL, 0, NULL);
sntprintf(buf, _countof(buf), _T("open \"%s\" alias ") SOUNDPLAY_ALIAS, aFilespec);
if (mciSendString(buf, NULL, 0, NULL)) // Failure.
return SetErrorLevelOrThrow();
g_SoundWasPlayed = true; // For use by Script's destructor.
if (mciSendString(_T("play ") SOUNDPLAY_ALIAS, NULL, 0, NULL)) // Failure.
return SetErrorLevelOrThrow();
// Otherwise, the sound is now playing.
g_ErrorLevel->Assign(ERRORLEVEL_NONE);
if (!aSleepUntilDone)
return OK;
// Otherwise, caller wants us to wait until the file is done playing. To allow our app to remain
// responsive during this time, use a loop that checks our message queue:
// Older method: "mciSendString("play " SOUNDPLAY_ALIAS " wait", NULL, 0, NULL)"
for (;;)
{
mciSendString(_T("status ") SOUNDPLAY_ALIAS _T(" mode"), buf, _countof(buf), NULL);
if (!*buf) // Probably can't happen given the state we're in.
break;
if (!_tcscmp(buf, _T("stopped"))) // The sound is done playing.
{
mciSendString(_T("close ") SOUNDPLAY_ALIAS, NULL, 0, NULL);
break;
}
// Sleep a little longer than normal because I'm not sure how much overhead
// and CPU utilization the above incurs:
MsgSleep(20);
}
return OK;
}
Code: Select all
TCHAR buf[MAX_PATH * 2]; // Allow room for filename and commands.
Code: Select all
sntprintf(buf, _countof(buf), _T("open \"%s\" alias ") SOUNDPLAY_ALIAS, aFilespec);
Following the next to last post to mmioOpen there is a interesting remark related to file names:jeeswg wrote: c++ - mciSendString won't play an audio file if path is too long - Stack Overflow
https://stackoverflow.com/questions/45221390/mcisendstring-wont-play-an-audio-file-if-path-is-too-long
Seemingly this function is still called for WAV files.Parameters
- szFilename
...
The file name should not be longer than 128 characters, including the terminating NULL character.
Users browsing this forum: Bing [Bot], krl and 38 guests