playd: Easy to use mplayer wrapper with playlist support

OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

I will. When i start mplayer, I get it's pid.
I save it in lock file.
Next time, I want to do something, i read lock file and get mplayers pid.

Then I run `pgrep mplayer` and get pids of all running mplayers.
If one pid match pid stored in lock file, that it's our mplayer, and it's running.
If not, we should $ playd restart


(well, That's how i planned it)


P.S.
I'm starting to redesign command line arguments. I want to be able to select multiple files/dirs at time
 
B

blah

Guest


killasmurf86 said:
I will. When i start mplayer, I get it's pid.
... and this PID immediately gets free'd - incorrect option. But it does appear in process list for some time and passes test with pgrep.
Code:
$ playd /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg
+ PLAYD_VERSION=1.2.4
+ 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_GENERIC_CMD=mplayer
+ MPLAYER_CMD=mplayer  --msglevel all=-1 quiet -idle -input file=/home/luser/.mplayer/playd.fifo
+ MPLAYER_SND_ONLY_CMD=mplayer  --msglevel all=-1 -vo null -quiet -idle -input file=/home/luser/.mplayer/playd.fifo
+ which mplayer
+ [ ! /home/luser/local/bin/mplayer ]
+ [ ! /home/luser ]
+ [ ! -d /home/luser/.mplayer ]
+ [ ! -p /home/luser/.mplayer/playd.fifo ]
+ mkfifo /home/luser/.mplayer/playd.fifo
+ [ /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg ]
+ [ -f /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg -o -d /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg ]
+ playd_start 0 silent
+ playd_check
+ [ -f /home/luser/.mplayer/playd.lock ]
+ return 0
+ [ 0 -eq 0 ]
+ cd /
+ [ 0 = novid ]
+ exec mplayer --msglevel all=-1 quiet -idle -input file=/home/luser/.mplayer/playd.fifo
+ echo 28915
+ playd_play /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg
+ rm -f /home/luser/.mplayer/playd_playlist.txt.tmp
+ playd_start 0 silent
+ playd_check
+ [ -f /home/luser/.mplayer/playd.lock ]
+ cat /home/luser/.mplayer/playd.lock
+ pidStored=28915
+ pgrep mplayer
+ [ 28915 = 28915 ]
+ return 28915
+ [ 28915 -eq 0 ]
+ [ silent != silent ]
+ [ -d /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg ]
+ [ -f /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg ]
+ playd_put loadfile '/d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg'
+ playd_check
+ [ -f /home/luser/.mplayer/playd.lock ]
+ cat /home/luser/.mplayer/playd.lock
+ pidStored=28915
+ pgrep mplayer
+ [ 28915 = 28915 ]
+ return 28915
+ [ 28915 -gt 0 ]
+ echo loadfile '/d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg'
load: 0.10  cmd: sh 28912 [fifoow] 1.30r 0.00u 0.00s 0% 1836k
load: 0.10  cmd: sh 28912 [fifoow] 1.70r 0.00u 0.00s 0% 1836k
^C/usr/local/bin/playd: cannot create /home/luser/.mplayer/playd.fifo: Interrupted system call
+ return 0
+ [  = 1 ]
+ echo Now playing file: '/d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg'
Now playing file: '/d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg'
+ rm -f /home/luser/.mplayer/playd_playlist.txt
+ echo /d/muz/ly/openbsd.4.4.trial_of_the_bsd_knights.ogg
+ exit 0
Simplified version
Code:
$ mplayer >&- 2>&- --msglevel all=-1 & ps lwwp $!
  UID   PID  PPID CPU PRI NI   VSZ   RSS MWCHAN STAT  TT       TIME COMMAND
 1001 29236 29235   0  44  0 40376  4268 zio->i D      5    0:00.00 mplayer --msglevel all=-1
$ ps lp $!
  UID   PID  PPID CPU PRI NI   VSZ   RSS MWCHAN STAT  TT       TIME COMMAND
[1]   Done (1)                mplayer --msglevel all=-1 >&- 2>&-
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

--msglevel was unsupported option (some kind of mistake, anyway, i removed it, since everything goes to /dev/null)

I think I fixed it

I rewrote pretty much of playd :D
v1.3.0 is out, for you to grab.

What's new:
* man page
* any number of arguments in command line
* cmdl syntax changed a bit, you may need to reconfigure you application settings (if you have integrated playd in window manager, like I did)
* code cleanup
* command aliases
* --file command
* probably something more, but I don't remember
* new bugs ???

Discovered bug, possible mplayers (check manpage bugs section)

p.s.
Your testing greatly appreciated


p.s.s.
now i go study for exam :D
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

uploaded playd v1.3.1

I've added a lot of new commands. Especially related to video (few more to be added in v1.3.2)
 
B

blah

Guest


Don't you have a repo (or a ,v-file for RCS/CVS)? It would be easier to find when each line was added and bug introduced. Especially when you remove URL's for previous versions from the first post.
 
B

blah

Guest


rcsintro(1) and put `,v' files in tarball. Though RCS is not so good for many files, e.g. if you decide to split playd into several files in future.
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

blah said:
rcsintro(1) and put `,v' files in tarball. Though RCS is not so good for many files, e.g. if you decide to split playd into several files in future.

I didn't like it....
(I will search for something)
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

I have finally move forward with playd.pl at rapid speed
I think in weak or two I could release it
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

Ok, here's my first release of playd v2
it's about the same as current version of playd v1, only difference is that it's written in perl, and seams to create playlists faster (up to 4 times)

http://code.google.com/p/playd/downloads/list
to run this version you need to install

devel/perl5.8 or devel/perl5.10
I have only tested on perl5.8

devel/p5-File-Type
multimedia/mplayer

EDIT:
also i have new blog where you can fallow playd....
http://killasmurf86.blogspot.com/
http://code.google.com/p/playd/
http://twitter.com/killasmurf86

EDIT:
UPDATE links (noticed someone digging here):
http://aldis.git.bsdroot.lv/playd.sh/
http://aldis.git.bsdroot.lv/playd.pl/ (deprecated)

Wiki
http://wiki.bsdroot.lv/playd
 

eye

Member

Reaction score: 9
Messages: 41

Hmm, playd-1.9.5 looks nice but...
  • About every command on my system respects $PAGER from environ()ment, playd being the only exception. I don't like how it exits at the end of text by default, makes scrolling playlist from the end more(1) annoying.
  • playd doesn't show current position in playlist, guess I'm spoiled by `xmms2 list'. At least it'd be nice if $ playd cmd get_file_name worked like `xmms2 current', i.e. showed current track.
  • typo: `sarution' vs. `saturation' in the manpage and `help' output
  • some places use `...`, some $(...); is such inconsistency intended?
 

UNIXgod

Daemon

Reaction score: 201
Messages: 1,088

Play a directory backwards:

% ls -1 -r * |mplayer -vo xv -fs -playlist -

Might even work this way
% mplayer -vo xv -fs -playlist `ls -r -1 *`
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

eye said:
Hmm, playd-1.9.5 looks nice but...
About every command on my system respects $PAGER from environ()ment, playd being the only exception. I don't like how it exits at the end of text by default, makes scrolling playlist from the end more(1) annoying.
actually I didn't thought about $PAGER, thanks I will fix it

eye said:
playd doesn't show current position in playlist, guess I'm spoiled by `xmms2 list'. At least it'd be nice if $ playd cmd get_file_name worked like `xmms2 current', i.e. showed current track.
By current design it is not possible... I don't know any way to get feedback from mplayer after I start it as daemon and redirect outputs to /dev/null. I control mplayer via pipe

eye said:
typo: `sarution' vs. `saturation' in the manpage and `help' output
Will fix it

eye said:
some places use `...`, some $(...); is such inconsistency intended?
There are actually some small differences between `...` and $(...)
Also playd started as very simple script that was generating fvwm menus, and it was my sh learning project... It was been modified gazillion times....

UNIXgod said:
Play a directory backwards:

% ls -1 -r * |mplayer -vo xv -fs -playlist -

Might even work this way
% mplayer -vo xv -fs -playlist `ls -r -1 *`

Ye, but playd generates playlist, and then loads it to mplayer. You can randomize playlist and load it to mplayer (which playd does, with rnd command), but you can't go back one song, because you don't know where you are in playlist :)
That's quite a problem....


I have to say, that I have an Idea, that might give playd opportunity to "know position in playlist" and play previous song, but It requires a Huge rethinking and rewriting....
Right now I don't have time for this.....

Meanwhile I use play already for like 1-2 years (maube 3, don't remember)

P.S.
Thanks for feedback
 

eye

Member

Reaction score: 9
Messages: 41

one more wish for your TODO: make playd remember position in playlist across daemon restarts (or reboots).
killasmurf86 said:
actually I didn't thought about $PAGER, thanks I will fix it
PR ports/152361 is not going to work correctly where $PAGER is not defined, just like $EDITOR, $LANG, $TZ, $TMPDIR, etc. are common to be left undefined.
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

eye said:
one more wish for your TODO: make playd remember position in playlist across daemon restarts (or reboots).
I told you I can't..... I don't know at any time what mplayer is playing

eye said:
PR ports/152361 is not going to work correctly where $PAGER is not defined, just like $EDITOR, $LANG, $TZ, $TMPDIR, etc. are common to be left undefined.

Ye, I was in rush.... (session is coming)
Will fix
 

eye

Member

Reaction score: 9
Messages: 41

If you're moving configuration from ~/.config/playd to ~/.config/playd/playd a note in UPDATING may be required.

BTW, is the git repo just for show? It still lists 1.9.5 as the last while that PR contains 1.9.9.
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

eye said:
If you're moving configuration from ~/.config/playd to ~/.config/playd/playd a note in UPDATING may be required.

BTW, is the git repo just for show? It still lists 1.9.5 as the last while that PR contains 1.9.9.

There are pretty much no configuration...
Crap.... now that is a bug :)
 

Beastie

Daemon

Reaction score: 548
Messages: 2,275

killasmurf86 said:
I told you I can't..... I don't know at any time what mplayer is playing
Anything preventing the use of the get_file_name command? Or am I misunderstanding something?
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

Beastie said:
Anything preventing the use of the get_file_name command? Or am I misunderstanding something?

Yup....
mplayer is very verbose... no matter how much you want to shut it up (at least as much as I have tried)
Since I want mplayer to run in background (because I often control it from fvwm, and I don't want HUGE log file) I redirect stdout & stderr to /dev/null. I don't have way to read output of mplayer.

The problem is that playd is written to execute commands and exit, while leaving mplayer in background.
Now imagine you have mplayer dameon and you tell playd to get file name, how would you read it's output? Even if mplayer output wasn't redirected, playd can't read mplayers output... unless you redirect that output to some pipe or file, this is a problem again, because, mplayer is writing a lot to output, and after about hour of playing, you have pretty big piece of text in pipe or file. This is not good.


If you have anyideas, how playd could be started and read mplayer output shoot....

One way to solve this could be to rewrite playd so that, mplayer is started as command command of sh (without & at the end.) and then keep playd script as daemon. This way I could know when mplayer stops playing track and thus know where in playlist we are....

But this requires significant rewrite.... I don't have time for this right now.
And I'm not sure how well it would work as well :)
 
OP
graudeejs

graudeejs

Son of Beastie

Reaction score: 707
Messages: 4,617

OK, I wrote functions to get info from mplayer (currently not pushed to repository)
The problem is that it's very easy to kill mplayer (I think it's mplayers bug)
I will investigate deeper, when I have more time... I will probably push changes in few hours
 

UNIXgod

Daemon

Reaction score: 201
Messages: 1,088

killasmurf86 said:
I have to say, that I have an Idea, that might give playd opportunity to "know position in playlist" and play previous song, but It requires a Huge rethinking and rewriting....
Right now I don't have time for this.....

Meanwhile I use play already for like 1-2 years (maube 3, don't remember)

P.S.
Thanks for feedback

make variables named prev and next

Set next to null (or whatever null is in that language) that way if it's the first pass it knows to generate a new next or use what is already been set of the user begins to use prev a couple of times.
 
Top