Every week I play an audio file with the GB2RS news over several repeaters, using the LOCALPLAY function.
I need to run some commands after the file playback is completed to put the system back to normal but as the file runs for a different duration each week, as the news is different, I need to find a way to detect when the playback has completed.
Any ideas on how to do this?
I thought maybe the events management subsystem might work for me but I can’t find much info or documentation about that, to enable me to learn enough about it to make it work. Some of the URLs for links to the old ohnosec site are now gone.
Thanks for any ideas or info received,
73,
Matt G4RKY
Programmatically detect the length of the audio file before playing it, so that when you execute the localplay command you can simply wait or sleep for the length of the audio file (maybe add 1 or 2 extra seconds for padding) before executing the rest of your commands.
As per my knowledge, One option is to use a script that monitors the playback status. You could set it up to detect when the playback process ends and then execute your commands. If you’re using a specific software for playback, check if it has a logging feature that indicates when playback completes.
I did try this and found that the next irem in the macro executes immediately after the audio playback commences! It was a while ago since I tried this, so I will try it again to be sure.
Hi Mason,
Thanks for your reply, but I don’t know how to programatically work out the length of playback of the file - all I know is the filesize in bytes - I imagine it can be done that way but no clue as to how to calculate the duration from that…
73,
Matt
Hi Roseanne23,
Thanks for your reply, in fact I am using the built in feature in Allstarlink to play the file back and ideally wanted to find a way within allstarlink to achieve this rather than start to use external scripts. As far as I know, Allstar uses an internal process to play the file, I don’t think it uses an external process for playback.
73’s
#!/bin/bash
# Path to the audio file
audio_file="path/to/your/audio/file.mp3"
# Get the duration of the audio file in seconds and add 2 seconds buffer
sleep_duration=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$audio_file")
sleep_duration=$(echo "$sleep_duration + 2" | bc)
# Sleep for the calculated duration
sleep "$sleep_duration"
# Execute the next command
echo "Sleeping for $sleep_duration seconds is complete. Executing the next command..."
# Add your next command here