joerg-krause writes

The onstart and onstop options can be set in the configuration file to run a command when the audio playback is about to begin or has ended.

The full path for the command has to be specified, e.g. /usr/bin/logger.

Executable scripts must begin with a shebang, e.g. #!/bin/sh.

Signed-off-by: Jörg Krause joerg.krause@embedded.rocks

medoc92 writes

Hi,

While I have no major issue with the change, I’d like to understand a bit more about it, if only to be able to document the purpose and intended usage: what is it ?

Depending on purpose, I’m also thinking that it may be interesting to give a little data about the song to the onstart command ?

Also, there is a dissimetry between the start and stop parts: onstart will only be triggered when upmdpcli plays something, not when another mpd client does it. onstop catches all mpd state changes.

Lastly, and also depending on intended purpose, would not this be more appropriately located closer to mpd ? I did not look into the details, but it seems that a shell script using the "mpc idle" command would be able to accomplish the same thing ?

joerg-krause writes

Sorry, I didn’t managed to do a second pull requests. Maybe I just try it with seperated branches next time.

> While I have no major issue with the change, I'd like to understand a bit more about it, if only to be able to document the purpose and intended usage: what is it ?

The main goal is to perform certain actions when playback begins/ends, like stopping another player, toggling an GPIO for poweron/shutdown an external amplifier, etc.

> Depending on purpose, I'm also thinking that it may be interesting to give a little data about the song to the onstart command ?

Yes, but this can be done with mpc already. But maybe any other UPnP related metadata?

> Also, there is a dissimetry between the start and stop parts: onstart will only be triggered when upmdpcli plays something, not when another mpd client does it. onstop catches all mpd state changes.

I see! For my case it is sufficient to know, when an UPnP playback begins, eg. a user pressed the Play button in BubbleUPnP and the user pressed the Stop button or the current playlist is empty. In the later case audio playback stops too, but I do not get a Stop command. That’s why I added the check to the updStatus(). Maybe there is a better solution to do this?

> Lastly, and also depending on intended purpose, would not this be more appropriately located closer to mpd ? I did not look into the details, but it seems that a shell script using the `mpc idle` command would be able to accomplish the same thing ?

The problem in my case is that mpd idle reports that the player has started. If I use a GPIO to wake up an external amplifier from standby mode, I will miss the first parts of the song. If I do it in upmpdcli when I am able to detect the "a Play button was pressed" event before mpd actually plays the audio stream.