Page 1 of 1
GTK gui to start/stop aplay (or wavplay)
Posted: Fri Dec 02, 2022 8:56 am
by greengeek
Not sure where to put this - but I would like to make a gtk gui that allows the user to select a wav file, then feed it to aplay and have start and stop buttons to control playback.
(Planning to use this when testing VanillaDpup which currently has no mplayer or deadbeef, but does have aplay - which handles wavs but not mp3)
Currently I just open a terminal and run aplay and type the file name but I would like to either have a file selector to choose the file or else rightclick the file and have it passed direct to the gui.
I can set up "open with" to get the file into aplay - but then I have no gui to stop playback and am relying on "killall aplay" to terminate it. I always get confused when trying to pass @u or similar arguments that specify the file name etc.
Does someone already have a basic gui on hand to achieve this please?
(VanillaDpup has very few libs and I am trying to get stuff done using the most basic of utilities)
EDIT Some useful options here:
- Thunor's PlayMusic pet works very well and is nicely configurable.
Doesnt matter if you only have basic audio utilities or massive codec/format support this simple utility is really worth a look:
viewtopic.php?p=74546#p74546
Re: GTK gui to start/stop aplay
Posted: Fri Dec 02, 2022 9:15 am
by MochiMoppel
greengeek wrote: Fri Dec 02, 2022 8:56 amDoes someone already have a basic gui on hand to achieve this please?
If "this" means controlling aplay then I don't know, but why not use ffplay (or avplay, depending on your distro)?
As GUI controls use mouse or better use the keyboard:
Code: Select all
FFplay window keyboard shortcuts:
PageUp go to end
PageDown go back to start
Right/Left 10sec forward/back
Up/Down 60sec forward/back
Space pause/restart
Esc or Q quit
Re: GTK gui to start/stop aplay
Posted: Fri Dec 02, 2022 9:35 am
by Jasper
@greengeek
If you want to build your own Gui you can grab the source file here:
https://code.google.com/archive/p/gtkdialog/
and a simple tutorial can be viewed here:
https://www.tecmint.com/gtkdialog-creat ... log-boxes/
Hope that helps!
Re: GTK gui to start/stop aplay
Posted: Fri Dec 02, 2022 4:17 pm
by jrb
aplay doesn't seem to have any pause function but here's a simple script that when you drag a wave file to it will open a terminal window and play your .wav file. To end play simply close window or Ctrl+c.
(Right click in any rox window and choose New-Script and then paste in the code.)
Code: Select all
#!/bin/sh
#open in terminal
tty -s; if [ $? -ne 0 ]; then xterm -hold -e "'$0' '$1'"; exit; fi
aplay "$1"
Cheers, J
Re: GTK gui to start/stop aplay
Posted: Fri Dec 02, 2022 7:13 pm
by some1
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 6:31 am
by greengeek
MochiMoppel wrote: Fri Dec 02, 2022 9:15 am
If "this" means controlling aplay then I don't know, but why not use ffplay (or avplay, depending on your distro)?
Thanks MM - unfortunately Vanilla has no ffmpeg or avconv ootb - and at this stage I am trying to see what I can achieve with as little added as possible. I am a big fan of ffmpeg but for now it is not the solution for me (yet).
(I am just using aplay to get some background music while I troubleshoot and configure the basic Vanilla pup)
Thank you - those are very handy. I will definitely find those useful.
Great link thanks. Some interesting ideas there!
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 6:32 am
by greengeek
jrb wrote: Fri Dec 02, 2022 4:17 pm
aplay doesn't seem to have any pause function but here's a simple script that when you drag a wave file to it will open a terminal window and play your .wav file. To end play simply close window or Ctrl+c.
(Right click in any rox window and choose New-Script and then paste in the code.)
Code: Select all
#!/bin/sh
#open in terminal
tty -s; if [ $? -ne 0 ]; then xterm -hold -e "'$0' '$1'"; exit; fi
aplay "$1"
Cheers, J
Thanks - working nicely. Of course now I want something extra 
Is there any way that this script could be modified to handle a whole directory of wavs dragged to it?
Cheers!
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 6:49 am
by greengeek
You know - all these years I have been reading the old forum - and only now did I see that Argolance's avatar is actually an animated gif - with a cheeky red tongue poking out at the end. Never noticed that before. 
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 8:05 am
by greengeek
I can use aplay to play each file in a directory of .wav files using the following script placed inside the music (wav file) directory:
Code: Select all
#! /bin/bash
for FILE in *; do aplay $FILE; done
I would be keen to find out how to modify that code to play only wav files in a directory of mixed media files (eg wav, mp3, ogg, flv etc etc)
(ie skipping the non-wav files without errors and without white noise for non wav files)
EDIT: of course it is simple to do so - just change * to *.wav
Code: Select all
#! /bin/bash
for FILE in *.wav; do aplay $FILE; done
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 8:47 am
by puppy_apprentice
Code: Select all
#!/bin/bash
shopt -s nullglob
for FILE in *.wav; do aplay $FILE; done
shopt -u nullglob
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 8:53 am
by greengeek
puppy_apprentice wrote: Sat Dec 03, 2022 8:47 am
Code: Select all
#!/bin/bash
shopt -s nullglob
for FILE in *.wav; do aplay $FILE; done
shopt -u nullglob
Nice. Thanks! Will experiment with this.
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 10:42 am
by HerrBert
greengeek wrote: Sat Dec 03, 2022 8:05 am
I can use aplay to play each file in a directory of .wav files using the following script placed inside the music (wav file) directory:
Code: Select all
#! /bin/bash
for FILE in *; do aplay $FILE; done
I would be keen to find out how to modify that code to play only wav files in a directory of mixed media files (eg wav, mp3, ogg, flv etc etc)
(ie skipping the non-wav files without errors and without white noise for non wav files)
Maybe thunor's PlayMusic - A Simple Lightweight GUI for Audio Players can do what you want.
Links on the old forum thread are broken...
I recall it is also part of gtkdialog source
github: https://github.com/oshazard/gtkdialog/t ... /playmusic
Re: GTK gui to start/stop aplay
Posted: Sat Dec 03, 2022 1:08 pm
by jrb
It's available in PPM (puppy-noarch-official). It says "mplayer" but IIRC you can set it to any audioplayer in the config file it creates in /root. You can also specify different players for different file types.
Re: GTK gui to start/stop aplay
Posted: Sun Dec 04, 2022 5:19 pm
by fredx181
Links on the old forum thread are broken...
Not very convenient, but workaround, change in the url: "murga-linux.com/puppy" to "oldforum.puppylinux.com"
For example change:
http://murga-linux.com/puppy/viewtopic.php?p=983208#983208
to:
http://oldforum.puppylinux.com/viewtopic.php?p=983208#983208
And paste in the address bar.
Re: GTK gui to start/stop aplay
Posted: Mon Dec 05, 2022 12:36 am
by greengeek
Excellent suggestion - thanks
jrb wrote: Sat Dec 03, 2022 1:08 pm
It's available in PPM (puppy-noarch-official). It says "mplayer" but IIRC you can set it to any audioplayer in the config file it creates in /root. You can also specify different players for different file types.
Thanks for the tip. Yes it is strange that "mplayer" is part of the name when it does not require mplayer at all.
In fact this utility is a pretty good fit for my needs. Surprisingly it defaults to using wavplay which I did not realise is already part of VanillaDpup.
Nice little gui and the only problem so far is that it takes quite a bit of time to sort through the music to find only wav files (which is all that the aplay and/or wavplay components can handle). Not a big issue and it seemed to get faster as time went on.
I still have plans to build my own gui using some of the other suggestions here. (I particularly liked the shopt glob method which seemed to work well in script form. I want to build that into a gui if i can)
Direct link to Thunors pet in ibiblio no-arch repository:
https://distro.ibiblio.org/puppylinux/p ... noarch.pet

- PlayMusicGui.jpg (11.63 KiB) Viewed 1586 times
Re: GTK gui to start/stop aplay (or wavplay)
Posted: Mon Dec 05, 2022 1:51 am
by greengeek
Using puppy_apprentice's shopt nullglob syntax I made 3 scripts which I can put in my music directory.
They allow me to start playing the wavs, step to the next wav, or kill the wav playing altogether.
I plan to make a gtk gui run these but for now they give me the basic control I need.
Unzip the attachment into the Music directory where the wavs can be found and click on each script as required.
(The 0- prefix helps keep the scripts displayed at the top of the window so you don't have to scroll too far to find them)
(The scripts must be "loose" inside the music directory - not buried in a subdirectory)

- wav-aplay_scripts.jpg (5.01 KiB) Viewed 1579 times