Play audio from script

  • Both /usr/bin/paplay and /usr/bin/aplay are included in libreelec so how would I play an audio file on a vanilla rpi2 on an hdmi TV? Tried a bunch of command line arguments and could not play an audio file from the command line.

  • I've tried both wav and mp3 but can't get anything to play from the command line/script. If a certain format works, I can convert the audio files to that. Note that libreelec (kodi) on rpi2 plays audio just fine on the hdmi tv.

  • Why not using Kodi and json for example:

    Code
    curl -H 'Content-Type: application/json' -d '{ "id": 1, "jsonrpc": "2.0", "method": "Player.Open", "params": {"item": { "file": "/storage/downloads/walking.in.the.sun.mp3" } } }' http://127.0.0.1:8080/jsonrpc
  • Make a playlist and play that. You need to decide based on your requirements.

    These are continuously running scripts monitoring/reporting real-time events. Unless a single file playlist will be synchronous/blocking or would play to completion should a subsequent single file playlist be sent, it's the same problem.

    Surely the included tools mentioned in post #1 can work with the proper arguments?

  • I'm new to libreelec but have years of openelec use. Which statement was unclear? It's not possible for a script to make a playlist now to announce all messages for future unknown events. The script could only create a playlist of the single file of the message it is trying to announce now. Would this playlist call be synchronous/blocking as opposed to the single file asynchronous/nonblocking method you gave in post #4? Do playlists always play to completion even if another playlist call is made. The single file play call you gave in post #4 does not block and if a second call is made too soon, the currently playing message aborts and the second one begins. Unless the single file playlist behavior is different than the single file behavior, we have the same problem.

    Since libreelec includes command line tools for playing audio files mentioned in post #1, there must be a way to use them right?

    Sorry if I came across as a spammer. I am genuinely trying to use "paplay" or "aplay" which are part of libreelec.