Play sound from terminal

On lsb linux plenty of tools exist to play e.g. A mp3 or wav file from the command line (such as aplay, wavplay sox, cvlc etc.). To my knowledge, not all of these are available for SfOS and none is preinstalled (is there any)?
Which one is recommended to install?
The goal I want to achive is writing a script to make some noise independend from the ringtone and speaker volumes set and start it from my amazfit watch on request through amazfish since I’m frequently misplacing my phone:)

1 Like

have you tried paplay ?

1 Like

paplay is the simple solution, but I keep pushing the difficult:

gst-launch-1.0 filesrc location=blah.ogg ! oggdemux ! vorbisdec !audioconvert ! audioresample ! pulsesink

needs the gstreamer1.0-tools to be installed. It’s really flexible :slight_smile:

1 Like

Hi, I use pkcon install mpg123 and play title.mp3.


paplay plays all file types that your libsndfile supports (wav flac opus ogg vorbis for jolla-libsndfile - additionally mp3 for libsndfile from openrepos)

gst-play-1.0 /path/to/your/file.mp3 will play an audio-file (internet-source possible too) , package gstreamer1.0-plugins-base-apps is needed for that.

1 Like

also plays video streams. does gst-play ? a quick look at the FAQ only shows it in use for audio? But in that case it’s easier to use than gst-launch.

on a desktop it does, on SFOS it tries but silently fails to open a window (playback of audio-stream of the video works) - it has something to do with the default videosink and its parameters - how do you get a working video-window with gst-launch ( ffplay from ffmpeg works perfectly for videos ) ?

How did you get ffplay on the device? :slight_smile: Usually I’m reading frame data from ffmpeg so I don’t know at what point I got it into my head that gst-launch works for video. I thought is was the droidvideotexturesink, but just tried all the sinks now and none of them display as you suggest:

gst-launch-1.0 filesrc location=/home/defaultuser/Videos/Oz-ramp-1.mp4 ! decodebin ! videoconvert ! droidvideotexturesink

Runs to the end but does not display.

the current ffmpeg-tools from openrepos ( search for ffplay ) provide ffplay and that works (using SDL as video-sink, so no hw-accel) – one can use it to play audio, too so it suits topic " Play sound from terminal"

for gstreamer: we would need but in the jolla-gst-plugins-bad-specfile it reads: remove waylandsink. It does not run because we do not support all the interfaces it needs.
maybe GitHub - pulkomandy/gstreamer-sdl2: GStreamer rendering to an SDL2 texture could be a starting point for gstreamer video playback from command line…

1 Like

Hi again - first of all, thanks for all the replies! Paplay does the trick for me - it’s especially nice that paplay respects the --volume parameter but doesn’t set the system volume peristently. Thus, it’s possible to let the phone ring at full volume even when it’s set silence, and it’s not necessary to mute it again afterwards. Now I can find my phone more easily with the help of my smartwatch:)