View Single Post
Posts: 43 | Thanked: 32 times | Joined on Jan 2010
#1
Hello.

When I want to listen to music in my car I have to:
- Select Menu
- Open Media Player
- Press the resume button
- Press "Now Playing" button
- Select FM Transmitter
- Enable FM Transmitter
- Save
- Press the play button.

This sucks!

I'm trying to do this with a script. Here's my (crappy) code:

Code:
#!/bin/sh

#TEXT FILE WITH THE PATH OF ALL SONGS
#TO CREATE THIS FILE: find -name "*.mp3" > /home/user/MyDocs/songs.txt
NAMES="/home/user/MyDocs/songs.txt"

if [ -f $NAMES ]
then
	#COUNT NUMBER OF SONGS 
	#wc -l $NAMES | cut -d ' ' -f 1` DOESN'T WORK IN N900
	NUMBER=0
	exec<$NAMES
	while read line
	do
	        NUMBER=`expr $NUMBER + 1`
	done

	"RANDOM" SONG
	#RANDOM VARIABLE EXISTS IN bash BUT NOT IN busybox
	max=$(($numero-1))
	random=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "`
	SONG=`head -$((1+($random % $max))) $FICHERO | tail -1`

	#TURNS FM TRANSMITTER ON
	fmtx_client -p 1

	#OPEN MEDIA PLAYER WITH THE RANDOM SONG
	dbus-send --print-reply --dest=com.nokia.mediaplayer /com/nokia/mediaplayer com.nokia.mediaplayer.mime_open string:"file:///$SONG
else
	echo "ERROR: The file $NAMES doesn't exist."
fi
This script selects a random song from disk, enables fm transmitter and plays the song with media player. It doesn't work very well: It only loads the random song and if I want to listen to another song I have to return to Media Player's main menu because there is no playlist, only the song (like when you open a music file with the file admin).

I'd like to create a script that enable FM Transmitter, open Media Player, load my playlist and resume playing.
After that I'd create a desktop button. I could listen to music in my car pressing only two buttons!

Is it possible? Can you help me?