PRO
afcorson
Australia
Asked
Detect When PC Audio Finishes
Is there a built-in variable named $PCPlayingAudio? If not, how can I determine when an audio file has finished playing? I'm using the PlayAudio(filename) function from an ARC script (JavaScript/Python) in my ARC project to play audio on the PC (not through an EZB).
Related Hardware (view all EZB hardware)
EZ-B V4
by EZ-Robot
EZ-B v4/2 robot controller: dual Cortex ARM, Wi-Fi, audio/video, 24 servo/digital ports, I2C/UART, camera and Synthiam ARC control for custom robots
Wi-Fi / USB
Servos
24
Camera
Audio
UART
3
I2C
ADC
8
Digital
24
Related Robot Skills (view all robot skills)
Nest
by Synthiam
MPU6050 Accelerometer Gyro Temperature
by Synthiam
Reads MPU6050 gyro, accelerometer and temperature via I2C, initializes and returns data on-demand to EZ-Script variables using ControlCommand RunOnce

There isn’t a built-in ARC global variable named
$PCPlayingAudiofor PC audio playback.For PC audio played with
Audio.playAudioFile(filename), the usual approach is:sleep(), if the file length is fixedBest simple solution: use your own flag
Since ARC doesn’t expose a built-in "PC audio is still playing" variable like it does for some EZB states, you can track it yourself in script.
JavaScript example
Better approach: use TTS audio from ARC and wait
If you’re using
Audio.saySSMLWait()orAudio.saySSML(), theWaitversion blocks until speaking is finished:That works for speech synthesis, but not for
Audio.playAudioFile().If you need to know when a file ends
ARC scripting does not currently provide a direct built-in callback or status variable for PC audio file playback completion. So your options are:
sleep()for that longWaitversionRelated variable note
ARC does have:
$EZBPlayingAudiofor EZB audio state$IsSpeakingfor speech stateBut those are not the same as PC audio file playback.
Helpful reference
Print()output: https://synthiam.com/Support/Programming/code-editor/consoleIf you want, I can help you write a small JavaScript or Python wrapper that plays a PC audio file and then automatically clears a flag after the correct duration.