playd: Easy to use mplayer wrapper with playlist support

That will cause problems if person suddenly wants to watch video, or something, however I have idea.... (a little complex to explaing and I'm short on time)

What is important now:
* Need to figure out how to fix playd on linux again :D
* Linux doesn't have procstat

probably need to look at /proc

Anyway, today I don't have time. I need to prepare myself for tomorrow. Tomorrow I will teach auditory of about 60 students (class mates) how to code Assembler in Un*x environment.
 
killasmurf86 said:
That will cause problems if person suddenly wants to watch video, or something, however I have idea.... (a little complex to explaing and I'm short on time)
Can you elaborate? No need to care about user that resets current playlist, he should use mplayer directly or with gui front-end rather than playd. Well, unless you plan to implement playlist sets and push video files in a separate playlist by default.
killasmurf86 said:
What is important now:
* Need to figure out how to fix playd on linux again :D
* Linux doesn't have procstat

probably need to look at /proc
Yep, figuring out files used by a process is system-dependent. That's why you should re-evaluate your approach with two-way communication in experimantal-mplayer-get branch. I think using fifo may be a bad idea, it's synchronous. The process sending to a named pipe is blocked until the data is read on another end. Regular files don't have this disadvantage. And -msglevel allows very precise control over mplayer output so filtering is rarely needed.

Also, does random command work on linux? jot(1) may not be available there.
 
I don't think you need both -msglevel all=-1 and -really-quiet. Also you can easily test linux sed(1) by installing textproc/gsed and defining wrapper at the start of the script.
Code:
alias sed=gsed # ex. 1
sed() { gsed "$@"; } # ex. 2
It's same for dash/bash, just swap shebang.

Note, sed(1) on 7.x and 8.0 doesn't have -r for gnu compat, it's very recent thing (r206538 was committed in Apr 2010). OTOH, gsed has -E for bsd compat for a bit longer time. Other BSDs seem to have both except for DragonFlyBSD which doesn't have -r.
 
I thought the change was obvious without diffs.
Code:
diff --git a/bin/playd.sh b/bin/playd.sh
--- a/bin/playd.sh
+++ b/bin/playd.sh
@@ -73,7 +73,7 @@ FORMAT_SPACES=${FORMAT_SPACES:-'yes'}
 
 
 # to customise mplayers command line set PLAYD_MPLAYER_USER_OPTIONS environment variable
-readonly MPLAYER_CMD_GENERIC="$PLAYD_MPLAYER_USER_OPTIONS -really-quiet -msglevel all=-1 -nomsgmodule -idle -input file=$PLAYD_PIPE"
+readonly MPLAYER_CMD_GENERIC="$PLAYD_MPLAYER_USER_OPTIONS -msglevel all=-1 -nomsgmodule -idle -input file=$PLAYD_PIPE"
 readonly MPLAYER_CMD="mplayer $MPLAYER_CMD_GENERIC"
 readonly MPLAYER_SND_ONLY_CMD="mplayer -vo null $MPLAYER_CMD_GENERIC"
 NOVID=0
@@ -375,21 +375,8 @@ playd_current_file_escaped() { # {{{1
 playd_cat_playlist() { # {{{1
 	if [ -f "$PLAYD_PLAYLIST" ]; then
 		if [ $FORMAT_SHORTNAMES = 'yes' -o $FORMAT_SHORTNAMES = 'YES' ]; then
-			if [ "$OS" = 'FreeBSD' ]; then
 				playd_longcat_playlist \
-					| sed -r \
-						-e 's#/.*/##' \
-						-e 's#_# #g' \
-						-e 's#^[ ]*##' \
-						-e 's# ?- ?[0-9]{1,2} ?- ?# - #' \
-						-e 's#-[0-9]{2}\.# - #' \
-						-E -e "s#\.($PLAYD_FILE_FORMATS)\$##" \
-						-E -e 's#\|  (([0-9][ -]?)?[0-9]{1,2}( - |\. |-|\.| ))?#|  #' \
-						-E -e 's#\|\* (([0-9][ -]?)?[0-9]{1,2}( - |\. |-|\.| ))?#|* #'
-			else
-				# assuming Linux
-				playd_longcat_playlist \
-					| sed -r \
+				| sed $(case $OS in (*BSD) printf -- -E;; (*) printf -- -r;; esac) \
 						-e 's#/.*/##' \
 						-e 's#_# #g' \
 						-e 's#^[ ]*##' \
@@ -398,7 +385,6 @@ playd_cat_playlist() { # {{{1
 						-e "s#\.($PLAYD_FILE_FORMATS)\$##" \
 						-e 's#\|  (([0-9][ -]?)?[0-9]{1,2}( - |\. |-|\.| ))?#|  #' \
 						-e 's#\|\* (([0-9][ -]?)?[0-9]{1,2}( - |\. |-|\.| ))?#|* #'
-			fi
 		else
 			if [ $FORMAT_SPACES = 'yes' -o $FORMAT_SPACES = 'YES' ]; then
 				playd_longcat_playlist | sed -e 's#/.*/##' -e 's#_# #g'
 
Released playd v1.16.0
In v1.16.0 I added support to save/restore playlist position :D

I wanted to note, that you can override some default playd variables in playd.conf (in playd home)

for example by default playd use $PAGER environment variable as pager.
IF you want to use other pager for playd exclusively, you can set
Code:
PAGER=more
in playd.conf
This is not documented in manual (yet), but you can check source, to see what you can override
 
Lately my mind is bugged by idea of storing playlists and such things in sqlite database :D
Need more thinking about this... but it would be very interesting challenge... That could give many benefits (I think)
 
Back
Top