maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   [HELP]Script to load Media Player and FM Transmitter (https://talk.maemo.org/showthread.php?t=70410)

isorn 2011-02-27 16:43

[HELP]Script to load Media Player and FM Transmitter
 
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?

droitwichgas 2011-02-27 16:58

Re: [HELP]Script to load Media Player and FM Transmitter
 
Why not just use the FM widget and the Music player widget, then just two button pressing does give you music via your car music player?

I use them every day without any problems.

Keneraali 2011-02-27 17:31

Re: [HELP]Script to load Media Player and FM Transmitter
 
I use this very simple script:

phone-control --fmtxon
phone-control --mp-resume launch

Of course you must have phone-control installed from the repos.

isorn 2011-02-27 19:56

Re: [HELP]Script to load Media Player and FM Transmitter
 
@droitwichgas
I've several widgets installed and I didn't want to install more but I'll install media player widget.

@Keneraali
I hadn't heard about phone-control, I'll give it a try.

Thank you.

kl2010 2011-06-29 04:48

Re: [HELP]Script to load Media Player and FM Transmitter
 
Quote:

Originally Posted by isorn (Post 956787)
@droitwichgas
I've several widgets installed and I didn't want to install more but I'll install media player widget.

@Keneraali
I hadn't heard about phone-control, I'll give it a try.

Thank you.

am trying to do the ame thing, mayb u can see here http://talk.maemo.org/showthread.php?t=70405&page=47


All times are GMT. The time now is 23:08.

vBulletin® Version 3.8.8