I am using this command to play music in the background (without GUI):
mplayer -shuffle -playlist /home/geppettvs/NAS/Musica/playlist.m3u </dev/null >/dev/null 2>&1 &
Which results in music being gathered from the Music folder in a NAS, which is played in the background.
The playlist itself is just a playlist file made with Rhythmbox or any other music player software with the ability to manage playlists.
So, mplayer starts with a random song after which it will continue uninterruptedly playing music.
What I need is to somehow query mplayer and ask it for the song name which is currently playing in order to place it somewhere, let's say: write it in a text file for later usage. (Just the filename without path)
Right now once mplayer starts playing music from the playlist, some efforts to query what is mplayer playing will result in "playlist.m3u" as the title name instead of the actual mp3 filename.
Alternatives
I am open for any alternatives, just as long as there is a better way of doing this without a GUI. Just let me know and I'll try it. Any ideas are welcomed.
Something like this crazy script should work:
Basically it works this way:
So now you have a way of grabbing the songs from a mplayer.
Note that the mplayer needs to be running for this to work since lsof checks open files.