Friday, 20 February 2009

EEE PC as Photo Frame - adding music

It would be nice to add some background music while watching a slideshow (see my previous post about making a slideshow script). After playing with that script I ended up with the following version:
#!/bin/sh

xset s off -dpms
mpg321 --random --quiet /path/to/music/files/*.mp3 &
qiv -sfmir -d 8 /path/to/picture/files/*.JPG
killall mpg321
xset s on +dpms
You should obviously replace "/path/to/music/files/" and "/path/to/picture/files/" to your actual locations.

Below is the short explanation of the changes.
I noticed that after 20 minutes the screen went blank, although screen-saver feature was disabled. The command
xset q
revealed, that DPMS (Display Power Management Signaling) feature was enabled, so I changed the first command in the script as follows:
xset s off -dpms
to switch DPMS totally off. The last command re-enables this feature.

Using my Package Finder tool I found that my EEE PC had pre-installed command-line audio player, called mpg321. It appeared that this program was quite suitable for our purposes.
mpg321 --random --quiet /path/to/music/files/*.mp3 &
The above command launches mpg321 player and tells it to play all mp3 files in the given folder in random order; the --quiet option supresses unnecessary text output. The "&" at the end tells the OS not to wait for the player finished its work, but go to the next line of the script.

When we terminated qiv, playing the slideshow, we also have to stop music. The command
killall mpg321
does the trick.

That's all.

No comments: