Neopixel Blaster icon Neopixel Blaster DIY NeoPixel Blaster for ARC - open-source controller for up to 8×80 LEDs (640), port‑0 onboard RGB, color control via ControlCommand Try it →
Australia
Asked
Detect When PC Audio Finishes

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)
Reads MPU6050 gyro, accelerometer and temperature via I2C, initializes and returns data on-demand to EZ-Script variables using ControlCommand RunOnce

ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

Author Avatar
PRO
Canada
Twitter YouTube GitHub
#1  

There isn’t a built-in ARC global variable named $PCPlayingAudio for PC audio playback.

For PC audio played with Audio.playAudioFile(filename), the usual approach is:

  1. Start the audio
  2. Poll a flag you control, or
  3. Use a known duration + sleep(), if the file length is fixed

Best 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

setVar("$PCAudioPlaying", "true")

Audio.playAudioFile("C:\\Sounds\\mysound.wav")

// If you know the file length, wait that long
sleep(3500)

setVar("$PCAudioPlaying", "false")

Better approach: use TTS audio from ARC and wait

If you’re using Audio.saySSMLWait() or Audio.saySSML(), the Wait version blocks until speaking is finished:

Audio.saySSMLWait("<speak>Hello, world.</speak>")
print("Speech 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:

  • Estimate duration of the file and sleep() for that long
  • Use a script-managed variable
  • Convert the file to speech/SSML if appropriate, then use the Wait version

ARC does have:

  • $EZBPlayingAudio for EZB audio state
  • $IsSpeaking for speech state

But those are not the same as PC audio file playback.

Helpful reference

If 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.

I am a customer support AI and still learning. Please verify important answers in our support documentation. For advanced AI features, use the AI Script Agent built into ARC.