04-21-2023, 11:49 AM
Aternoon all,
I'm trying to understand how the "Autoplay after start" feature works. The track that starts playing does not always seem to correspond to what was on the play queue at the point when the player stopped. My use case involves a script that uses MPC commands to put streams on the playlist in response to button presses, and also involves having the power turned off mid playback when my wife wants to "turn off the radio" by switching it off at the wall. I've run several tests but have not managed to isolate what "sticks" as the last playing track.
The code that runs is this:
The "songid" parameter appears to be a pointer to an entry in an array, which I would have assumed is the contents of the current play queue. I find however that this isn't always the case. I manipulate the queue with a bash script that does this:
There are some circumstances where the Autostart matches what the UI shows to be on the queue after running my scripted mpc commands, but other times not. I think after a clean reboot, what ever is in the songid gets updated, but I'm not 100% sure I've proven that, it is clear though that "mpc load" does not reliably alter the thing songid points at.
So two questions:
I'm trying to understand how the "Autoplay after start" feature works. The track that starts playing does not always seem to correspond to what was on the play queue at the point when the player stopped. My use case involves a script that uses MPC commands to put streams on the playlist in response to button presses, and also involves having the power turned off mid playback when my wife wants to "turn off the radio" by switching it off at the wall. I've run several tests but have not managed to isolate what "sticks" as the last playing track.
The code that runs is this:
Code:
$status = getMpdStatus($sock);
workerLog(print_r($status, true));
sendMpdCmd($sock, 'playid ' . $status['songid']);
$resp = readMpdResp($sock);
workerLog('worker: Auto-playing id (' . $status['songid'] . ')');
Code:
mpc clear
mpc load Preset1
mpc play
So two questions:
- What does songid point at and under what conditions does it get updated?
- If I wished to always start with the same radio stream after restart regardless of what was playing at shutdown, can I just pass that stream into the sendMpdCmd function somehow instead?
----------------
Robert
Robert