playd: Easy to use mplayer wrapper with playlist support

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

playd is a simple to use mplayer wrapper script.

Playd was designed to avoid installing mplayer GUI, which are far from perfect.

playd starts mplayer in slave mode and controls it with pipe.
It only depends on mplayer and FreeBSD base system (it can be ported to other systems)

It's possible to integrate playd in desktop environment (assign commands to shortcuts, integrate in menu, etc...)

Command line arguments are simple and easy to remember.


Features:
  • Extremely easy to use
  • Supports creation and playing of simple plain text playlists
  • 1 dependency (multimedia/mplayer)
  • Very fast and small
  • K.I.S.S. - Keep It Small & Simple

I think it's perfect for people who want to use mplayer for everything.

new versions will be announced on this thread with link attached

Please, let me know about bugs in playd here

playd is available in ports collection:
multimedia/playd


[EDIT]
http://hg.bsdroot.lv/pub/aldis/playd.sh/
http://wiki.bsdroot.lv/playd
 

vivek

Aspiring Daemon

Reaction score: 197
Messages: 805

I use the -playlist option:
Code:
mplayer -playlist mp3.list
Will try out this one too.
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

vivek said:
I use the -playlist option:
Code:
mplayer -playlist mp3.list
Will try out this one too.

you won't need do keep virtual terminal opened. And still be able to pause, skip tracks etc.

Edit:
It also makes playlists ;)
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

seams playd 1.1.5 will be available in ports any day now
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

playd is now available in ports

for some reason commiter named it multimedia/dplay after you install you need to run playd....

I already emailed on this matter, and either I will change name to dplay or port will be renamed to playd (I prefer 2nd choice)
 
B

blah

Guest


Some garbage crept in
Code:
@@ -76,7 +76,7 @@ some_file [0|1]                   - play
 some_dir [0|1]                    - play dir
 
 http://playlist.on.net.m3u        - play internet stream (radio in this example)
-ftp://ftp.me.com/cool_movie.avi   - play stream from ftp serverYD_HOME/
+ftp://ftp.me.com/cool_movie.avi   - play stream from ftp server
 playlist [cusom_playlist] [0|1]   - play playlist [1=append, 0=new playlist]
 play ID                           - play specific item from playlist
Wouldn't it be better to rely on ~/.mplayer/config for video output drivers and software scaling? MPlayer already tries xv first and then falls back to x11. Some drivers may be undesirable (e.g. dga), so it's better to not hardcode them.
Code:
@@ -51,7 +51,7 @@ PLAYD_PLAYLIST="$PLAYD_HOME/playd_playli
 PLAYD_LOCK="$PLAYD_HOME/playd.lock"
 
 MPLAYER_VERBOCITY=-1
-MPLAYER_CMD="mplayer -vo xv,x11,xvidix,gl,dga -zoom -msglevel all=$MPLAYER_VERBOCITY -quiet -idle -input file=$PLAYD_PIPE"
+MPLAYER_CMD="mplayer -msglevel all=$MPLAYER_VERBOCITY -quiet -idle -input file=$PLAYD_PIPE"
 MPLAYER_SND_ONLY_CMD="mplayer -vo null -msglevel all=$MPLAYER_VERBOCITY -quiet -idle -input file=$PLAYD_PIPE"
 
 # print help
Why you discourage other schemes:// ?
I like to fill my playlist with entries from smb:// hosts
Code:
@@ -405,7 +405,7 @@ if [ "$1" ]; then
 			echo 'loadfile dvd://' > "$PLAYD_PIPE"
 		;;
 
-		'http://'* | 'ftp://'* )
+		*'://'* )
 			playd_start '0' 'silent'
 			echo "loadfile $1" > "$PLAYD_PIPE"
 		;;
mplayer spams to attached terminal on any error in audio/video stream. I think it's better to redirect stderr to /dev/null or just close ( `2>&-' ) it.
Code:
mpg123: Can't rewind stream by 184 bits!
...
[flac @ 0x804a4e110]FRAME HEADER not here
Last message repeated 4 times
[flac @ 0x804a4e110]invalid sample size code (3)
[flac @ 0x804a4e110]invalid frame header
[flac @ 0x804a4e110]decode_frame() failed
[flac @ 0x804a4e110]FRAME HEADER not here
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

I fixed lines you mentioned.
The reasons mplayer_cmd line existed at all, is that few months ago, i had problem with mplayer, that is now fixed, at that time, it was much more easier to edit playd and fix mplayer with command line, than to read how to edit ~/.mplayer/config

--------

How to redirect stderr to /dev/null?


or just close ( `2>&-' ) it.
I don't really understand this (where and how to add? At the end of mplayer_cmd right?)

--------

Hey, i was also wondering, how could i check file extensions? (I need some awk/sed help on this)
This could speed up making playlists by factor ~20-30


I have started writing playd2 in perl. After some thinking I decided to check for extensions first and then fall back to mime, because many mp3's report their mime as application/octet-stream. In playd.sh i simply added them to playlist, which is wrong, because there are other file types, that report to be application/octet-stream.
 
B

blah

Guest


Here is some bug
Code:
$ sh -x $(which playd) stop
+ PLAYD_VERSION=1.1.5
+ PLAYD_HOME=/home/luser/.mplayer
+ PLAYD_PIPE=/home/luser/.mplayer/playd.fifo
+ PLAYD_PLAYLIST=/home/luser/.mplayer/playd_playlist.txt
+ PLAYD_LOCK=/home/luser/.mplayer/playd.lock
+ MPLAYER_VERBOCITY=-1
+ MPLAYER_CMD=mplayer -vo xv,x11,xvidix,gl,dga -zoom -msglevel all=-1 -quiet -idle -input file=/home/luser/.mplayer/playd.fifo
+ MPLAYER_SND_ONLY_CMD=mplayer -vo null -msglevel all=-1 -quiet -idle -input file=/home/luser/.mplayer/playd.fifo
+ [ ! /home/luser ]
+ [ ! -d /home/luser/.mplayer ]
+ [ ! -p /home/luser/.mplayer/playd.fifo ]
+ mplayer_instaled=no
+ echo /usr/local/libexec/ccache:/usr/local/libexec/usr:/home/luser/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/luser/bin:/home/luser/local/bin
+ tr :
+ [ -f /usr/local/libexec/ccache/mplayer ]
+ [ -f /usr/local/libexec/usr/mplayer ]
+ [ -f /home/luser/local/bin/mplayer ]
+ mplayer_instaled=yes
+ break
+ [ yes = no ]
+ [ stop ]
+ playd_stop
+ playd_check
+ [ -f /home/luser/.mplayer/playd.lock ]
+ cat /home/luser/.mplayer/playd.lock
+ pidStored=12071
+ pgrep mplayer
+ [ 12071 = 12071 ]
+ return 12071
+ [ 12071 = 0 ]
+ echo quit
+ playd_check
+ [ -f /home/luser/.mplayer/playd.lock ]
+ cat /home/luser/.mplayer/playd.lock
+ pidStored=12071
+ pgrep mplayer
+ [ 12071 = 12071 ]
+ return 12071
+ [ 12071 != 0 ]
+ kill 0
zsh: terminated  sh -x $(which playd) stop
Spotted on 8-CURRENT. Look at PID of the kill'd process. Possible fix is to NOT rely on exit code
Code:
@@ -105,19 +105,22 @@ playd_check() {
 		# probably won't find mplayer if launched with console
 		# potential bug
 		for pid in `pgrep mplayer`; do
-			if [ "$pid" = "$pidStored" ]; then return "$pidStored"; fi
+			if [ "$pid" = "$pidStored" ]; then
+			    echo $pidStored
+			    return
+			fi
 		done
 		rm -f "$PLAYD_LOCK"
 	fi
-	return 0
+	echo 0
 }
 
 
 # start daemon
 playd_start() {
-	playd_check
+	local pid=$(playd_check)
 
-	if [ "$?" -eq 0 ]; then
+	if [ $pid -eq 0 ]; then
 		if [ "$1" = 'novid' ]; then
 			cd /
 			exec $MPLAYER_SND_ONLY_CMD > /dev/null 2> /dev/null &
@@ -139,14 +142,14 @@ playd_start() {
 
 # stop daemon
 playd_stop() {
-	playd_check
-	if [ "$?" = 0 ]; then
+	local pid=$(playd_check)
+
+	if [ $pid -eq 0 ]; then
 		echo 'playd is not running'
 	else
 		echo 'quit' >> "$PLAYD_PIPE"
-		playd_check
-		if [ "$?" != 0 ]; then
-			kill "$?"
+		if [ $pid -ne 0 ]; then
+			kill $pid
 			rm -f "$PLAYD_LOCK"
 		fi
 	fi
@@ -260,7 +263,7 @@ if [ $mplayer_instaled = 'no' ]; then
 	exit 1
 fi
 
-
+pid=$(playd_check)
 
 # check command line arguments
 if [ "$1" ]; then
@@ -350,8 +353,7 @@ if [ "$1" ]; then
 		;;
 
 		'mute' )
-			playd_check
-			if [ ! "$?" = 0 ]; then
+			if [ $pid -ne 0 ]; then
 				echo 'mute' > "$PLAYD_PIPE"
 			else
 				echo "playd doesn't seam to be running"
@@ -359,8 +361,7 @@ if [ "$1" ]; then
 		;;
 
 		'pause' )
-			playd_check
-			if [ ! "$?" = 0 ]; then
+			if [ $pid -ne 0 ]; then
 				echo 'pause' > "$PLAYD_PIPE"
 			else
 				echo "playd doesn't seam to be running"
@@ -368,8 +369,7 @@ if [ "$1" ]; then
 		;;
 
 		'seek' )
-			playd_check
-			if [ ! "$?" = 0 ]; then
+			if [ $pid -ne 0 ]; then
 				echo "seek $2 $3" > "$PLAYD_PIPE"
 			else
 				echo "playd doesn't seam to be running"
@@ -377,8 +377,7 @@ if [ "$1" ]; then
 		;;
 
 		'next' )
-			playd_check
-			if [ ! "$?" = 0 ]; then
+			if [ $pid -ne 0 ]; then
 				echo "seek 100 1" > "$PLAYD_PIPE"
 			else
 				echo "playd doesn't seam to be running"
@@ -386,8 +385,7 @@ if [ "$1" ]; then
 		;;
 
 		'status' )
-			playd_check
-			if [ "$?" = 0 ]; then
+			if [ $pid -eq 0 ]; then
 				echo 'playd is not running'
 			else
 				echo 'play is running'
There is some obvious code duplication in case statement that can be removed with simple function that sends string into pipe
Code:
# put argv into pipe
# ex.: playd_put seek 100
playd_put() {
    local pid=$(playd_check)

    if [ $pid -ne 0 ]; then
	echo "$@" >> "$PLAYD_PIPE"
    else
	echo "playd doesn't seam to be running"
	return 1
    fi
}
So you can use smth like this in case statement
Code:
		'seek' )
			playd_put seek $2 $3
		;;
killasmurf86 said:
How to redirect stderr to /dev/null?
$ foo 2>/dev/null
Code:
@@ -120,11 +120,11 @@ playd_start() {
 	if [ "$?" -eq 0 ]; then
 		if [ "$1" = 'novid' ]; then
 			cd /
-			exec ${MPLAYER_SND_ONLY_CMD} >> /dev/null &
+			exec $MPLAYER_SND_ONLY_CMD > /dev/null 2> /dev/null &
 			echo "$!" > "$PLAYD_LOCK"
 		else
 			cd /
-			exec ${MPLAYER_CMD} >> /dev/null &
+			exec $MPLAYER_CMD > /dev/null 2> /dev/null &
 			echo "$!" > "$PLAYD_LOCK"
 		fi
 	else
killasmurf86 said:
Hey, i was also wondering, how could i check file extensions? (I need some awk/sed help on this)
This could speed up making playlists by factor ~20-30
Code:
$ foo=smb://host/pub/muz/ly/openbsd.4.5.games.ogg

$ foo_ext=${foo##*.}; echo $foo_ext
ogg

$ foo_dir=${foo%/*}; echo $foo_dir
smb://host/pub/muz/ly
$ dirname $foo
smb://host/pub/muz/ly

$ foo_base=${foo##*/}; echo $foo_base
openbsd.4.5.games.ogg
$ basename $foo
openbsd.4.5.games.ogg
It's explained in section Parameter Expansion in sh(1). Try this
Code:
@@ -170,7 +170,7 @@ playd_mk_playlist() {
 					# for some reason i have seen some mp3's to be reported as "application/octet-stream"
 					# because of that playd didn't play them earlier.
 					# thsi fixes the problem.... hopefully i will find better solution
-					if [ $(file -ib "$1/$fileName" | tr " " "_") = 'application/octet-stream' ]; then
+					if [ "${fileName##*.}" = 'mp3' ]; then
 						echo "$1/$fileName" >> "$PLAYD_PLAYLIST.tmp"
 					fi
 				;;
killasmurf86 said:
I decided to check for extensions first and then fall back to mime, because many mp3's report their mime as application/octet-stream.
I'd rely on mime-type and if it's application/octet-stream only then check extension. This way some_file.mp3 that is actually text/plain wouldn't end up in playlist by accident.
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

But there's also questions performance vs correctness

If differance is small, that i'd prefer correctness.
But on perl, i have gained performance boost up to x30 by checking extensions first.
(i recall numbers 2m vs 4s, i will provide results once my I/O Buffer is clean)




Let's face the fact:
How often do you see text file with mp3 extension?

The file that is reported as application/octet-stream could as well be plain text (i have seen some) and have mp3 extension....
it would be very rear case...

that's why I would prefer to check extension and fallback to mime
 
B

blah

Guest


killasmurf86 said:
on perl, i have gained performance boost up to x30 by checking extensions first.
Since you already do benchmarks how about pure shell (except file(1) + cut(1)) vs. pure perl traversing directories
Code:
#! /bin/sh

# generate playlist from file/directory
# usage: playd_mk_playlist <file | directory>
playd_mk_playlist() {
    for fileName in "$1"/*; do
	# XXX: recursion is slower than simple `while' loop
	if [ -d "$fileName" ]; then
	    playd_mk_playlist "$fileName"
	fi
	case "${fileName##*.}" in
	    mp3 );;
	    ogg );;
	    flac );;
	    avi );;
	    mkv );;
	    * ) # no known extension found, try mime-type then
		mime=$(file -ib "$fileName" | cut -d\; -f1)
		case $mime in
		    audio* | video* );;
		    * ) continue # jump to next file
		esac
	esac
	# finally, add file
	echo adding \"$fileName\"
#	echo "$fileName" >> "$PLAYD_PLAYLIST.tmp"
    done
}

set -o xtrace
playd_mk_playlist /d/muz
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

I run test on 2454 music files (with some crap files in directories)

my test showed:
1m 7s to 1m 20 when checking mime first and fallback to extensions
vs
3s to 5s when checking extensions first fallback to mime


I think numbers speak clearly


P.S.
I modified your code and implemented it directly
 
B

blah

Guest


Please, keep lines under 80 chars long. They don't fit on my screen (xterm on 1600x1200, DejaVu Sans Mono-24).

BTW, why not add failiem.lv as a mirror for distfile into port
Code:
Index: multimedia/playd/Makefile
===================================================================
RCS file: /home/csup/ports/multimedia/playd/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- multimedia/playd/Makefile	9 Jun 2009 16:04:31 -0000	1.1
+++ multimedia/playd/Makefile	12 Jun 2009 12:53:26 -0000
@@ -8,13 +8,17 @@
 PORTNAME=	playd
 PORTVERSION=	1.1.5
 CATEGORIES=	multimedia
-MASTER_SITES=	http://www.logvinov.ru/files/dist/playd/
+MASTER_SITES=	http://www.logvinov.ru/files/dist/playd/ \
+		http://www.failiem.lv/down.php?i=${MAGIC_KEY}&n=
 
 MAINTAINER=	killasmurf86@gmail.com
 COMMENT=	Very easy to use mplayer sh wrapper script, with usefull features
 
 RUN_DEPENDS=	mplayer:${PORTSDIR}/multimedia/mplayer
 
+FETCH_BEFORE_ARGS=	-o${DISTFILES}
+MAGIC_KEY=	qqekrf
+
 PLIST_FILES=	bin/playd
 
 NO_BUILD=	yes
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

blah said:
Please, keep lines under 80 chars. They doesn't fit on my screen` (xterm on 1600x1200, DejaVu Sans Mono-24).

OH, brother, why do you use such a big font? on such a big screen, on X?




blah said:
BTW, why not add failiem.lv as a mirror for distfile into port
Code:
Index: multimedia/playd/Makefile
===================================================================
RCS file: /home/csup/ports/multimedia/playd/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- multimedia/playd/Makefile	9 Jun 2009 16:04:31 -0000	1.1
+++ multimedia/playd/Makefile	12 Jun 2009 12:53:26 -0000
@@ -8,13 +8,17 @@
 PORTNAME=	playd
 PORTVERSION=	1.1.5
 CATEGORIES=	multimedia
-MASTER_SITES=	http://www.logvinov.ru/files/dist/playd/
+MASTER_SITES=	http://www.logvinov.ru/files/dist/playd/ \
+		http://www.failiem.lv/down.php?i=${MAGIC_KEY}&n=
 
 MAINTAINER=	killasmurf86@gmail.com
 COMMENT=	Very easy to use mplayer sh wrapper script, with usefull features
 
 RUN_DEPENDS=	mplayer:${PORTSDIR}/multimedia/mplayer
 
+FETCH_BEFORE_ARGS=	-o${DISTFILES}
+MAGIC_KEY=	qqekrf
+
 PLIST_FILES=	bin/playd
 
 NO_BUILD=	yes

Originally Port had failiem.lv as mirror...
for some reason portlint yells, that mirror doesn't end with /

Before that I didn't thought of MAGIC_KEY.... (this is pretty much my first port)
I'll speak to committer about that.

EDIT:
fixed misspelling
 
B

blah

Guest


Code:
'vol' )
	mixer pcm ${2}
;;
After ariff@ introduced VPC (Volume Per Channel) changing master pcm volume directly is a bad idea. Better would be to use mplayer slave interface.

[cmd=]playd_put volume $2 $3[/cmd]

BTW, I think there should be playd command that allows passing arguments directly to mplayer. It would be useful when one needs to send some less frequent command like `loop'.
Code:
'quote' )
	shift
	playd_put $@
;;
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

blah said:
Code:
'vol' )
	mixer pcm ${2}
;;
After ariff@ introduced VPC (Volume Per Channel) changing master pcm volume directly is a bad idea. Better would be to use mplayer slave interface.

[cmd=]playd_put volume $2 $3[/cmd]

BTW, I think there should be playd command that allows passing arguments directly to mplayer. It would be useful when one needs to send some less frequent command like `loop'.
Code:
'quote' )
	shift
	playd_put $@
;;

Implemented (look at first post for link to new version)
 
B

blah

Guest


[cmd=]PLAYD_HOME=$HOME/.mplayer
PLAYD_PIPE=$PLAYD_HOME/playd.fifo
PLAYD_PLAYLIST=$PLAYD_HOME/playd_playlist.txt
PLAYD_LOCK=$PLAYD_HOME/playd.lock[/cmd]
It's safe to assume that all path variables (may) contain spaces.
# pw user add test -md '/home/foo bar' ($HOME with spaces inbetween)
# su -l test
$ sh -x $(which playd) start
+ PLAYD_VERSION=1.2.1
+ PLAYD_HOME=/home/foo bar/.mplayer
+ PLAYD_PIPE=/home/foo bar/.mplayer/playd.fifo
+ PLAYD_PLAYLIST=/home/foo bar/.mplayer/playd_playlist.txt
+ PLAYD_LOCK=/home/foo bar/.mplayer/playd.lock
+ MPLAYER_VERBOCITY=-1
+ MPLAYER_GENERIC_CMD=mplayer -msglevel all=-1
+ MPLAYER_CMD=mplayer -msglevel all=-1 -quiet -idle -input file=/home/foo bar/.mplayer/playd.fifo
+ MPLAYER_SND_ONLY_CMD=mplayer -msglevel all=-1 -vo null -quiet -idle -input file=/home/foo bar/.mplayer/playd.fifo
+ which mplayer
+ [ ! /home/foo bar/bin/mplayer ]
[: /home/foo: unexpected operator
+ [ ! /home/foo bar ]
[: /home/foo: unexpected operator
+ [ ! -d /home/foo bar/.mplayer ]
[: /home/foo: unexpected operator
+ [ ! -p /home/foo bar/.mplayer/playd.fifo ]
[: /home/foo: unexpected operator
+ [ start ]
+ playd_start
+ playd_check
+ [ -f /home/foo bar/.mplayer/playd.lock ]
[: /home/foo: unexpected operator
+ return 0
+ [ 0 -eq 0 ]
+ [ = novid ]
[: =: unexpected operator
+ cd /
+ exec mplayer -msglevel all=-1 -quiet -idle -input file=/home/foo bar/.mplayer/playd.fifo
+ echo 26533
+ exit 0


There is another bug on `playd start'. It's because $1 undefined. In such a case one can enclose varable in double quotes so when test evaluates it becomes string with only NUL char.
$ [ $blah = foo ]
[: =: unexpected operator

$ echo $?
2

$ [ "$blah" = foo ]
$ echo $?
1


$ playd stop
load: 0.08 cmd: sh 27830 [fifoow] 0.35r 0.00u 0.00s 0% 1788k

Appeared: 1.2.0
Possible cause: playd_put sends data to a disconnected named pipe in playd_stop
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

dam....
I had all variables double quoted.... and then one day i unquoted them (something strike me)


grrrrrrrrrrrr, i'm mad at me....
Will fix ASAP
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

fixed (i found some more bugs myself), hopefully no more bugs. lol

This was good lesson for me:
If you quote everything don't remove quotes later :D

link as usually on 1st post
EDIT:

Uploaded v1.2.3
 
B

blah

Guest


Code:
playd_stop() {
	playd_put quit
	if [ ! "$?" ]; then
$ [ ! "0" ] && echo not zero
$ [ ! "1" ] && echo not non-zero
Both tests return non-zero (false). `$?' needs to be null string or undefined for test to return 0 (true). Is this intended?

Here is a specific for 1.2.3, MPLAYER_CMD related:
[cmd=]mplayer --msglevel all=-1
Unknown option on the command line: --msglevel
Error parsing option on the command line: --msglevel
MPlayer SVN-r29362-4.5.0 (C) 2000-2009 MPlayer Team[/cmd]
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

another bug
Code:
--- playd-1.2.3/playd	2009-06-13 13:17:31.299309947 +0300
+++ playd-1.2.4/playd	2009-06-15 23:14:09.546677243 +0300
@@ -40,7 +40,7 @@
 # BUGS: there are probably some, but they aren't pretty important
 # However if you find them, or can tell me how to reproduce them let me know :D
 
-PLAYD_VERSION="1.2.3"
+PLAYD_VERSION="1.2.4"
 
 PLAYD_HOME="$HOME/.mplayer"
 PLAYD_PIPE="$PLAYD_HOME/playd.fifo"
@@ -105,7 +105,7 @@
 # put argv into pipe
 playd_put() {
 	playd_check
-	if [ "$?" -ne 0 ]; then
+	if [ $? -gt 0 ]; then
 		echo "$@" >> "$PLAYD_PIPE"
 		return 0
 	fi
@@ -133,7 +133,7 @@
 playd_start() {
 	playd_check
 
-	if [ "$?" -eq 0 ]; then
+	if [ $? -eq 0 ]; then
 		cd /
 		if [ "$1" = 'novid' ]; then
 			exec ${MPLAYER_SND_ONLY_CMD} > /dev/null 2> /dev/null &
@@ -155,20 +155,20 @@
 # stop playd daemon
 playd_stop() {
 	playd_put quit
-	if [ ! "$?" ]; then
+	if [ $? -gt 0 ]; then
 		sleep 1 # give mplayer 1s to quit
 		playd_check
-		kill_pid="$?"
-		if [ "$kill_pid" ]; then
+		kill_pid=$?
+		if [ $kill_pid -gt 0 ]; then
 			kill "$kill_pid"
 			sleep 1
 			playd_check
-			kill_pid="$?"
-			if [ "$kill_pid" ]; then
+			kill_pid=$?
+			if [ $kill_pid -gt 0 ]; then
 				kill -9 "$kill_pid"
 				sleep 1
 				playd_check
-				if [ "$?" ]; then
+				if [ $? -gt 0 ]; then
 					echo "can't kill mplayer"
 					return 1
 				fi
@@ -230,7 +230,7 @@
 	if [ -d "$1" ]; then
 		playd_mk_playlist "$1"
 
-		if [ "$2" = 1 ]; then
+		if [ "$2" = "1" ]; then
 			echo "directory '$1' appended to current playlist"
 			else
 			echo "Now playing directory: '$1'"
@@ -242,7 +242,7 @@
 	elif [ -f "$1" ]; then
 		playd_put "loadfile '$1' $2"
 
-		if [ "$2" = 1 ]; then
+		if [ "$2" = "1" ]; then
 			echo "file '$1' appended to current playlist"
 			else
 			echo "Now playing file: '$1'"
@@ -281,7 +281,7 @@
 
 if [ ! -d "$PLAYD_HOME" ]; then
 	mkdir "$PLAYD_HOME"
-	if [ "$?" != 0 ]; then
+	if [ $? -gt 0 ]; then
 		echo "Can't create $PLAYD_HOME"
 		echo 'Exiting'
 	fi
@@ -394,10 +394,10 @@
 
 		'status' )
 			playd_check
-			if [ "$?" = 0 ]; then
-				echo 'playd is not running'
-			else
+			if [ $? -gt 0 ]; then
 				echo 'play is running'
+			else
+				echo 'playd is not running'
 			fi
 		;;
 
B

blah

Guest


blah said:
Here is a specific for 1.2.3, MPLAYER_CMD related:
[cmd=]mplayer --msglevel all=-1
Unknown option on the command line: --msglevel
Error parsing option on the command line: --msglevel
MPlayer SVN-r29362-4.5.0 (C) 2000-2009 MPlayer Team[/cmd]
And this one?
Code:
MPLAYER_CMD="$MPLAYER_GENERIC_CMD --msglevel all=-1 quiet -idle -input file=$PLAYD_PIPE"
stderr being redirected to null device you'll not find out why mplayer doesn't start
 
Top