You are not logged in.

#1 2013-07-11 19:13:55

kisawk
Member
Registered: 2013-07-11
Posts: 5

[SOLVED] Starting mplayer automatically after boot

I tried to achieve that by editing ~/.bash_profile as below, but I still get the same error. However when I run the same command in terminal everything works fine. It looks like system haven't yet fully started when the mplayer is started, but I don't know hot to handle it.

~bash_profile

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

mplayer -slave -playlist /home/$USER/er.m3u 1&>/home/$USER/mplayer.log &

Result

MPlayer SVN-r36285-4.7.2 (C) 2000-2013 MPlayer Team
205 audio & 424 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing http://stream.radioer.pl:8000/Radio_eR.
Resolving stream.radioer.pl for AF_INET...

Couldn't resolve name for AF_INET: stream.radioer.pl
STREAM_ASF, URL: http://stream.radioer.pl:8000/Radio_eR
Resolving stream.radioer.pl for AF_INET...

Couldn't resolve name for AF_INET: stream.radioer.pl
Failed, exiting.
Resolving stream.radioer.pl for AF_INET...

Couldn't resolve name for AF_INET: stream.radioer.pl
No stream found to handle url http://stream.radioer.pl:8000/Radio_eR


Playing 1.
File not found: '1'
Failed to open 1.


Exiting... (End of file)

Does anyone know how to fix that or run mplayer after boot some other way?

Last edited by kisawk (2013-07-12 00:49:42)

Offline

#2 2013-07-11 20:41:10

leflore
Member
From: Columbus, OH
Registered: 2013-07-09
Posts: 11

Re: [SOLVED] Starting mplayer automatically after boot

What exactly are you trying to accomplish? You can't start mplayer after boot because there's no X session running. Are you trying to start it after login?


"Whoever has ears, let him hear"

Offline

#3 2013-07-11 20:47:53

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Starting mplayer automatically after boot

OP doesn't need X as it's a radio playlist.

Offline

#4 2013-07-11 20:52:13

johnride
Member
Registered: 2012-04-28
Posts: 16

Re: [SOLVED] Starting mplayer automatically after boot

This looks pretty much like a network error, you could try to write a systemd service that depends on dhcpcd being fully started or hack you bashrc by putting a condition like ping your radio server. I guess there is a simple way to know if you have a fully functionnal network connection but I don't know it.

Offline

#5 2013-07-11 21:11:02

kisawk
Member
Registered: 2013-07-11
Posts: 5

Re: [SOLVED] Starting mplayer automatically after boot

Mplayer can work without X server. Generally speaking I want to run slideshow with music in the background. I need whole thing to run automatically after reboot in case of blackout and I thought it would be easier to accomplish without X server.

Going back to the topic - I delayed executing mplayer by 10 seconds and it works properly.

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

sleep 10
mplayer -slave -playlist /home/$USER/er.m3u 1&>/home/$USER/mplayer.log &

Still, I don't want to leave it this way. Any ideas what is causing the problem?

Offline

#6 2013-07-11 21:20:04

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Starting mplayer automatically after boot

kisawk, are you sure your network is up when you log in?

Offline

#7 2013-07-11 21:36:42

kisawk
Member
Registered: 2013-07-11
Posts: 5

Re: [SOLVED] Starting mplayer automatically after boot

As I said earlier everything must start without user participation, so I use autologin. Is there any way to check if network is up (and wait until it will be) before running mplayer?

Offline

#8 2013-07-11 22:17:42

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] Starting mplayer automatically after boot

As (kinda) already advised, use a while loop that pings that radio server.

Offline

#9 2013-07-12 00:17:24

kisawk
Member
Registered: 2013-07-11
Posts: 5

Re: [SOLVED] Starting mplayer automatically after boot

It took me two hours, but it works! Thank you very much.

~/.bash_profile

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

while : 
do
    if ping.sh stream.radioer.pl
    then
        break
    fi
done

mplayer -slave -playlist /home/$USER/er.m3u 1&>/home/$USER/mplayer.log &

and ping.sh

#!/bin/sh
ping -c 1 "$1" > /dev/null

There is one more thing. Although I redirected output from ping to /dev/null, I still get this error each time ping.sh is executed.

ping: unknown host stream.radioer.pl

Can I get rid of it somehow?

Offline

#10 2013-07-12 00:21:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Starting mplayer automatically after boot

Change '> /dev/null' to '2> /dev/null':

$ ping -c1 foobar >/dev/null
ping: unknown host foobar
$ ping -c1 foobar 2>/dev/null
$

to redirect the errors.

Offline

#11 2013-07-12 00:49:13

kisawk
Member
Registered: 2013-07-11
Posts: 5

Re: [SOLVED] Starting mplayer automatically after boot

Works great. Thanks again.

Offline

#12 2013-07-12 00:53:44

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Starting mplayer automatically after boot

It works the same ways as '1&>/home/$USER/mplayer.log' you have in your script.
http://en.wikipedia.org/wiki/Redirectio … le_handles
'0' is standard input, '1' is standard output and '2' is standard error.

Offline

#13 2013-07-12 02:53:59

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: [SOLVED] Starting mplayer automatically after boot

@karol: Thanks. Have always wondered but never found out.

Offline

Board footer

Powered by FluxBB