ports/141578: ports: playd2 update
Aldis Berjoza
killasmurf86 at gmail.com
Tue Dec 15 07:10:03 UTC 2009
>Number: 141578
>Category: ports
>Synopsis: ports: playd2 update
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: maintainer-update
>Submitter-Id: current-users
>Arrival-Date: Tue Dec 15 07:10:03 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Aldis Berjoza
>Release: FreeBSD 8.0-RELEASE-p1 i386
>Organization:
>Environment:
System: FreeBSD 8.0-RELEASE-p1 #1: Sun Dec 13 22:39:39 EET 2009
killasmurf86 at killasmurf86.pc:/usr/obj/usr/src/sys/ANTIGENERIC
>Description:
I decided to move playd2 files to port.... they are only 2 files, and bough are very small
Sorry for trouble.
P.S.
if this is unsacceptible, I will find hosting for port source.
>How-To-Repeat:
>Fix:
--- playd2.patch begins here ---
diff -rNu playd2.bak/Makefile playd2/Makefile
--- playd2.bak/Makefile 2009-08-15 17:10:13.000000000 +0300
+++ playd2/Makefile 2009-12-15 08:48:33.899710077 +0200
@@ -8,7 +8,8 @@
PORTNAME= playd2
PORTVERSION= 2.1.2
CATEGORIES= multimedia
-MASTER_SITES= ${MASTER_SITE_GOOGLE_CODE}
+MASTER_SITES= # none
+DISTFILES= # none
MAINTAINER= killasmurf86 at gmail.com
COMMENT= Very easy to use mplayer Perl wrapper script, with useful features
@@ -17,16 +18,15 @@
${LOCALBASE}/${SITE_PERL_REL}/File/Type.pm:${PORTSDIR}/devel/p5-File-Type
CONFLICTS= playd-1.[0-9]*
-PROJECTHOST= playd
PLIST_FILES= bin/playd
MAN1= playd.1
-WRKSRC= ${WRKDIR}/playd2
NO_BUILD= yes
+SUB_FILES= playd.pl
USE_PERL5_RUN= 5.8.9+
do-install:
- ${INSTALL_SCRIPT} ${WRKSRC}/playd.pl ${PREFIX}/bin/playd
- ${INSTALL_MAN} ${WRKSRC}/playd.1 ${PREFIX}/man/man1/
+ ${INSTALL_SCRIPT} ${WRKDIR}/playd.pl ${PREFIX}/bin/playd
+ ${INSTALL_MAN} ${FILESDIR}/playd.1 ${PREFIX}/man/man1/
.include <bsd.port.mk>
diff -rNu playd2.bak/distinfo playd2/distinfo
--- playd2.bak/distinfo 2009-08-15 17:10:13.000000000 +0300
+++ playd2/distinfo 1970-01-01 03:00:00.000000000 +0300
@@ -1,3 +0,0 @@
-MD5 (playd2-2.1.2.tar.gz) = 634c7d8987d5967f2a5344d303dfac2c
-SHA256 (playd2-2.1.2.tar.gz) = 5e860c970670a06b214b575002988f7d498d63d1096eef733a850a5f881833b2
-SIZE (playd2-2.1.2.tar.gz) = 7786
diff -rNu playd2.bak/files/playd.1 playd2/files/playd.1
--- playd2.bak/files/playd.1 1970-01-01 03:00:00.000000000 +0300
+++ playd2/files/playd.1 2009-12-15 08:40:23.211910092 +0200
@@ -0,0 +1,226 @@
+.\" Copyright (c) 2009, Aldis Berjoza <killasmurf86 at gmail.com>
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions are
+.\" met:
+.\"
+.\" * Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" * Redistributions in binary form must reproduce the above
+.\" copyright notice, this list of conditions and the following disclaimer
+.\" in the documentation and/or other materials provided with the
+.\" distribution.
+.\" * Neither the name of the nor the names of its
+.\" contributors may be used to endorse or promote products derived from
+.\" this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" .Dd June 16, 2009
+.TH playd 1 "July 3, 2009" "playd v2.0+" "playd v2 manual"
+.SH NAME
+\fBplayd\fP - simple to use mplayer perl wrapper script
+.SH SYNOPSIS
+\fBplayd\fP [ \fB--append\fP ] [ \fIoptions\fP ] [ \fIfiles\fP | \fIdirectories\fP | \fIstream\fP ] ...
+.SH DESCRIPTION
+Playd is simple mplayer perl wrapper script.
+With playd you don't need mplayer gui, to listen to music, watch wideos, stream video/audio.
+Playd stores it's playlist is simple plain text files, containing file names with absolute path.
+Playd automatically creates playlist if nessacery.
+It is easy to integreate playd in various window managers (i.e. fvwm2, fluxbox), scripts etc.
+
+Playd is designed K.I.S.S.
+Goal is to be small, fast and very easy to use.
+The goal is not to be as foolproof as possible.
+.SH OPTIONS
+Options can be mixed almost in any order.
+There's only one limit: \fB--append\fP must be 1st argument, if specified.
+.SS --append
+Applend items to default playlist.
+Must be first argument on command line if used.
+.SS --audio-delay \fIvalue\fP [ --absolute ]
+Adjust audio delay in seconds (relative by default).
+If \fB--absolute\fP is set, then audio delay will be set exactly to value seconds.
+.SS --cd [ \fItrack\fP ] ...
+Play audio CD.
+(Can't append to playlist)
+.SS --cmd "\fImplayer comman\fP"
+Send command to mplayer slave directly.
+If command contain spaces, it should be quoted.
+For mplayer slave commands see
+
+http://www.mplayerhq.hu/DOCS/tech/slave.txt
+.SS --brightness \fIvalue\fP [ --absolute ]
+Adjust brightness by value (relative by default).
+If \fB--absolute\fP key is specified, brightness will be set to absolute value.
+Value can be in range -100 to 100.
+.SS --contrast \fIvalue\fP [ --absolute ]
+Adjust contrast by value (relative by default).
+If \fB--absolute\fP key is specified, contrast will be set to absolute value.
+Value can be in range -100 to 100.
+.SS --dvd [ \fItrack\fP ]
+Play video DVD.
+(Can't append to playlist)
+.SS --file [ \fIfile\fP | \fIdirectory\fP ]
+Play file or directory.
+This option is handy if you have file name that match playd command
+.SS --gamma \fIvalue\fP [ --absolute ]
+Adjust gamma by value (relative by default).
+If \fB--absolute\fP key is specified, gamma will be set to absolute value.
+Value can be in range -100 to 100.
+.SS --hue \fIvalue\fP [ --absolute ]
+Adjust hye by value (relative by default).
+If \fB--absolute\fP key is specified, hue will be set to absolute value.
+Value can be in range -100 to 100.
+.SS --list
+Show default playlist.
+.SS --longlist
+Show default plaulist.
+Each item is displayed with full path.
+.SS --loop \fIvalue\fP [ --absolute ]
+How many times to loop current playlist item.
+If \fIvalue\fP == 0, item will be looped forever.
+By default value is added to current playlists loop count.
+Use \fB--absolute\fP to set absolute count of times, playlist item should be looped.
+.SS --mute
+Mute mplayer slave.
+.SS --next
+Play next playlist item.
+.SS --nocheck \fIfile\fP
+There are some files that are reported as application/octet-stream.
+These can be various types, even text files.
+If you can't load some file, you can try using this option.
+It won't check for file type and extension.
+This can be very usefull for disk images.
+Note, that you need to set \fB--nocheck\fP for every file you want playd to skip filetype checks.
+.SS --pause
+Pause mplayer slave.
+.SS --play \fIitem1\fP [\fIitem2\fP] ...
+Play items from default playlist.
+.SS --playlist [\fIcustom-playlist\fP]
+Play simple text playlist.
+Playd will play default playlist if no playlist is specified.
+Mplayer slave will be automatically started if nessacery.
+.SS --randomize
+This will randomize playlist, but won't start playing it... you'll need to run \fBplayd --playlist\fP to load new playlist.
+.SS --repeat
+Repeat current playlist item again.
+.SS --restart [ --novid ] [ --console ]
+Sometime playd doesn't listen to your commands.
+Actually playd does listend, while mplayer doesn't.
+So if you don't get expeced behavior from playd, please run \fBplayd --restart\fP and check if everything works.
+Only send bug report if same problem apears after restart.
+If \fB--novid\fP is set, mplayer will only output sound.
+If \fB--fork\fP is set, mplayer playd will show mplayer output to current terminal.
+.SS --rmlist
+Remove default playlist.
+.SS --seek \fIvalue\fP\fB[m|h]\fP [ --absolute | --precent ]
+Seek current file to value.
+If \fB--absolute\fP is specified, seek to absolute value in seconds.
+If \fB--precent\fP is specified, seek to value percent.
+By default mplayer slave will seak relative in seconds.
+You can yse \fBm\fP and \fBh\fP modifiers to specify minutes and hours (they can't be used with \fB--percent\fP).
+.SS --sarution \fIvalue\fP [ --absolute ]
+Adjust sarution by value (relative by default).
+If \fB--absolute\fP key is specified, sarution will be set to absolute value.
+Value can be in range -100 to 100.
+.SS --start [ --novid ] [ --console ]
+Start mplayer slave.
+You won't probably need to use this, because mplayer slave is started automatically when needed.
+If \fB--novid\fP is set, mplayer will only output sound.
+If \fB--fork\fP is set, mplayer playd will show mplayer output to current terminal.
+.SS --status
+Check if mplayer is started in slave mode.
+.\" .SS --subtitles \fIfile\fP
+.\" Load subtitles.
+.\" This optiond doesn't check for filetype.
+.\"
+.\" NOTE: this option is untested.
+.\" If it works, or doesn't please send email to killasmurf86 at gmail.com
+.SS --quit
+Stop mplayer slave.
+.SS --switch-audio
+Cycle through the available audio tracks.
+(for DVD)
+.SS --switch-subtitle
+Cycle through the available subtitle tracks.
+(for DVD)
+.SS --volume \fIvalue\fP [ --absolute ]
+Adjust volume by value (relative by default).
+If \fB--absolute\fP key is specified, volume will be set to absolute value.
+Value can be 0 - 100
+.SS \fIfile\fP | \fIdirectory\fP | \fIstream\fP
+play file, directory or stream.
+Mplayer will be automatically started in slave mode, if nessacery.
+.SH "COMMAND ALIASES"
+Every command that starts with \fB--\fP, has alias witout it (they aren't mentioned here)
+
+ \--absolute abs
+ \--append -a
+ \--cd -c cdda
+ \--dvd -d
+ \--file -f
+ \--help -h
+ \--list -l
+ \--longlist -L --llist
+ \--mute -m
+ \--next -n
+ \--pause -z
+ \--percent %
+ \--play -p
+ \--playlist -P
+ \--randomize --rnd
+ \--restart -R
+ \--seek -s
+ \--quit -q --stop
+ \--switch-audio --sw-audio
+ \--switch-subtitles --sw-sub
+ \--subtitles -S --subs
+ \--volume -v --vol
+.SH ENVIRONMENT
+Set PLAYD_MPLAYER_USER_OPTIONS, to add custom command line options passed to mplayer, when it's started.
+
+Set PLAYD_HOME, if you want to change playd home directory.
+By default it uses ~/.mplayer
+.SH EXAMPLES
+playd /my/mysic
+
+playd --append /mysic/1.mp3 /music/3.mp3
+
+playd play 1 3 5
+
+playd http://yp.shoutcast.com/sbin/tunein-station.pls?id=656847
+
+playd stop
+.SH NOTES
+As of v1.3.x there are several differences in command line syntax compared to older versions.
+If you have integrated playd in your window manager, script etc... you should modify your config to match new syntax.
+
+\fB--nofork\fP is renamed to \fB--console\fP
+
+\fB--stop\fP is renamed to \fB--quit\fP, but since mplayer slave mode command stop doesn't seam to work, \fB--stop\fP for now is an alias for \fB--quit\fP
+.SH HOMEPAGE
+http://code.google.com/p/playd/
+
+http://killasmurf86.blogspot.com/search/label/playd
+.SH SEE ALSO
+mplayer(1)
+perl(1)
+.SH AUTHORS
+Aldis Berjoza <killasmurf86 at gmail.com>
+.SH BUGS
+Seams \fB--play\fP doesn't work well (if at all) after using \fB--next\fP or \fB--seek\fP.
+I think it's mplayer bug (still testing if it's playd bug).
+After you restart playd, everything seams work as expected.
+
+Read \fB--restart\fP
diff -rNu playd2.bak/files/playd.pl.in playd2/files/playd.pl.in
--- playd2.bak/files/playd.pl.in 1970-01-01 03:00:00.000000000 +0300
+++ playd2/files/playd.pl.in 2009-12-15 08:40:23.210895158 +0200
@@ -0,0 +1,622 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2009, Aldis Berjoza <killasmurf86 at gmail.com>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of the nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# It's ugly down there :D
+
+###################################
+# DEPENDENCIES
+###################################
+# perl
+# devel/p5-File-Type
+# multimedia/mplayer
+###################################
+
+package playd;
+
+use warnings;
+use strict;
+
+use Cwd qw(abs_path getcwd);
+use Errno qw(EAGAIN);
+use File::Type;
+use POSIX qw(mkfifo);
+use File::Spec::Functions qw(rootdir);
+use List::Util qw(shuffle);
+
+my $v_major = 2;
+my $v_minor = 1;
+my $v_update = 2;
+my $v_devel = 0;
+my $playd_version = "$v_major.$v_minor.$v_update";
+$playd_version .= "_$v_devel" if $v_devel;
+
+(my $playd_name = $0) =~ s/.*?\///g; # what's my name?
+
+# some common variables
+my $playd_home = "$ENV{HOME}/.config/playd2";
+my $playd_lock = "$playd_home/lock";
+my $playd_fifo = "$playd_home/fifo";
+my $playd_playlist = "$playd_home/playlist.plst";
+my $playd_tmp_playlist = "$playd_home/tmp_playlist.plst";
+my $playd_mplayer_cmd = "mplayer -idle -input file=$playd_fifo";
+my $playd_mplayer_no_video_cmd = "mplayer -vo /dev/null -idle -input file=$playd_fifo";
+my $playd_append = 0;
+my $playd_novid = 0;
+my $playd_console = 0;
+my $playd_mplayer_user_options = '';
+
+my $ft = File::Type->new();
+
+unless ( -d $playd_home ) {
+ mkdir($playd_home, 0700) or die "ERR: can't create directory '$playd_home'.\n$!\n";
+}
+
+unless ( -p $playd_fifo ) {
+ mkfifo($playd_fifo, 0600) or die "ERR: can't create fifo '$playd_home'.\n$!\n";
+}
+
+&get_args() if ( defined $ARGV[0] );
+&help();
+exit;
+
+#########################################################################################
+#########################################################################################
+#########################################################################################
+
+sub get_args {
+ if ( $ARGV[0] =~ /^((--)??append|-a)$/ ) {
+ shift @ARGV;
+ $playd_append = 1;
+ }
+
+ while ( $ARGV[0] ) {
+
+# --append
+ if ( $ARGV[0] =~ /^((--)??append|-a)$/ ) {
+ warn "WARN: '$ARGV[0]' should be first argument on command line. Ignoring\n";
+ }
+
+# --cd
+# --dvd
+ elsif ( $ARGV[0] =~ /^((--)??(cd(da)??|dvd)|-c|-d)$/ ) {
+ my $media;
+ $media = 'cdda' if ( $ARGV[0] =~ /^((--)??cd(da)??|-c)$/ );
+ $media = 'dvd' if ( $ARGV[0] =~ /^((--)??dvd|-d)$/ );
+
+ if ( defined $ARGV[1] and $ARGV[1] =~ /^\d$/ ) {
+ while ( $ARGV[1] =~ /^\d$/ ) {
+ &add_to_playlist("$media://$ARGV[1]");
+ shift @ARGV;
+ }
+ }
+ else {
+ &add_to_playlist("$media://");
+ }
+ }
+
+# --help
+ elsif ( $ARGV[0] =~ /^((--)??help|-h)$/ ) {
+ &help;
+ }
+
+# --list
+ elsif ( $ARGV[0] =~ /^((--)??list|-l)$/ ) {
+ &list(0);
+ }
+
+# --longlist
+ elsif ( $ARGV[0] =~ /^((--)??l(ong)??list|-L)$/ ) {
+ &list(1);
+ }
+
+# --mute
+ elsif ( $ARGV[0] =~ /^((--)??mute|-m)$/ ) {
+ &send_mplayer_cmd('mute');
+ }
+
+# --playlist
+ elsif ( $ARGV[0] =~ /^((--)??playlist|-P)$/ ) {
+ if ( defined $ARGV[1] and -f $ARGV[1] and $ARGV[1] =~ /\.plst^/ ) {
+ &start;
+ &send_mplayer_cmd("loadlist $ARGV[1] $playd_append");
+ $playd_append = 1;
+ shift @ARGV;
+ }
+ elsif ( -f $playd_playlist ) {
+ &start;
+ &send_mplayer_cmd("loadlist '$playd_playlist' $playd_append");
+ $playd_append = 1;
+ }
+ else {
+ warn "WARN: default playlist is not available. Ignoring\n";
+ }
+ }
+
+# --play
+ elsif ( $ARGV[0] =~ /^((--)??play|-p)$/ ) {
+ if ( defined $ARGV[1] and $ARGV[1] =~ /^\d+$/ ) {
+ &start;
+ open(PLAYLIST, '<', $playd_playlist) or die "ERR: can't open file '$playd_playlist'.\n$!\n";
+ my @item_pos;
+ push(@item_pos, 0);
+ while ( my $item = <PLAYLIST> ) {
+ push(@item_pos, tell(PLAYLIST));
+ }
+
+ my @tmp_list;
+ while ( defined $ARGV[1] and $ARGV[1] =~ /^\d+$/ ) {
+ if ( defined $item_pos[ $ARGV[1] - 1 ] ) {
+ seek(PLAYLIST, $item_pos[$ARGV[1] - 1], 0);
+ push(@tmp_list, my $tmp_item = <PLAYLIST>);
+ }
+ else {
+ warn "WARN: there's no playlist item with number '$ARGV[1]'. Ignoring\n";
+ }
+ shift @ARGV;
+ }
+ close PLAYLIST;
+
+ open (TMP_PLAYLIST, '>', $playd_tmp_playlist) or die "ERR: can\'t open file '$playd_tmp_playlist' for writing.\n$!\n";
+ print TMP_PLAYLIST @tmp_list;
+ close TMP_PLAYLIST;
+ &send_mplayer_cmd("loadlist '$playd_tmp_playlist' $playd_append");
+ $playd_append = 1;
+ sleep 1;
+ unlink $playd_tmp_playlist;
+
+ }
+ }
+
+# --randomize
+ elsif ( $ARGV[0] =~ /^(--)??(randomize|rnd)$/ ) {
+ open(PLAYLIST, '<', $playd_playlist) or die "ERR: can't open file '$playd_playlist'.\n$!\n";
+ my @item_pos;
+ push(@item_pos, 0);
+ while ( my $item = <PLAYLIST> ) {
+ push(@item_pos, tell(PLAYLIST));
+ }
+ pop @item_pos, my $playlist_eof; # I don't need to know that
+
+ open (TMP_PLAYLIST, '>', $playd_tmp_playlist) or die "ERR: can\'t open file '$playd_tmp_playlist' for writing.\n$!\n";
+ @item_pos = shuffle(@item_pos);
+ foreach my $item (@item_pos) {
+ seek(PLAYLIST, $item, 0);
+ my $entry = <PLAYLIST>;
+ print TMP_PLAYLIST $entry;
+ }
+
+ close PLAYLIST;
+ close TMP_PLAYLIST;
+ unlink $playd_playlist;
+ rename $playd_tmp_playlist, $playd_playlist;
+ }
+
+# --quit
+ elsif ( $ARGV[0] =~ /^((--)??(quit|stop)|-q)$/ ) {
+ &quit;
+ }
+
+# --status
+ elsif ( $ARGV[0] =~ /^((--)??status|-i)$/ ) {
+ my $pid = &get_mplayer_pid;
+ if ( $pid ) {
+ print "playd is running. PID: $pid\n";
+ }
+ else {
+ print "playd is not running\n";
+ }
+ }
+
+# --restart
+ elsif ( $ARGV[0] =~ /^((--)??restart|-R)$/ ) {
+ shift @ARGV if ( defined $ARGV[1] and $playd_novid = $ARGV[1] =~ /^(--)??novid$/ );
+ shift @ARGV if ( defined $ARGV[1] and $playd_console = $ARGV[1] =~ /^(--)??console$/ );
+ &quit;
+ &start;
+ }
+
+# --seek
+ elsif ( $ARGV[0] =~ /^((--)??seek|-s)$/ ) {
+ if ( defined $ARGV[1] and $ARGV[1] =~ /^[+-]??(\d+|\0)(m|h)??$/ ) {
+ ( my $seek_time ) = $ARGV[1] =~ /^(\d+)/;
+ $seek_time *= 60 if ( $ARGV[1] =~ /m$/ );
+ $seek_time *= 3600 if ( $ARGV[1] =~ /h$/ );
+
+ if ( defined $ARGV[2] and $ARGV[2] =~ /^(--)??abs(olute)??$/ ) {
+ &send_mplayer_cmd("seek $seek_time 2");
+ shift @ARGV;
+ shift @ARGV;
+ }
+ elsif ( defined $ARGV[2] and $ARGV[2] =~ /^(--)??percent|%$/ ) {
+ unless ( $ARGV[1] =~ /(m|h)$/ ) {
+ &send_mplayer_cmd("seek $ARGV[1] 1");
+ shift @ARGV;
+ shift @ARGV;
+ }
+ else {
+ warn "WARN: $ARGV[2] doesn't support 'm' and 'h' modifiers. Ignoring\n";
+ shift @ARGV;
+ shift @ARGV;
+ }
+ }
+ else {
+ &send_mplayer_cmd("seek $seek_time 0");
+ shift @ARGV
+ }
+ }
+ else {
+ warn "WARN: $ARGV[0] needs at least numerica argument. Ignoring\n";
+ }
+ }
+
+ elsif ( $ARGV[0] =~ /^((--)??start|-S)$/ ) {
+ shift @ARGV if ( defined $ARGV[1] and $playd_novid = $ARGV[1] =~ /^(--)??novid$/ );
+ shift @ARGV if ( defined $ARGV[1] and $playd_console = $ARGV[1] =~ /^(--)??console$/ );
+ &start;
+ }
+
+# --volume
+# --brightness
+# --contrast
+# --gamma
+# --hue
+# --saturation
+# --audio-delay
+# --loop
+ elsif ( $ARGV[0] =~ /^((--)??(vol(ume)??|brightness|contrast|gamma|hue|saturation|audio-delay|loop)|-v)$/ ) {
+ my $parameter = $ARGV[0];
+ $parameter =~ tr/-//;
+ $parameter = 'audio_delay' if ( $parameter =~ /audiodelay/ );
+ $parameter = 'volume' if ( $parameter =~ /vol(ume)??|V/ );
+
+ if ( defined $ARGV[1] and $ARGV[1] =~ /^[+-]??\d+$/ ) {
+ if ( defined $ARGV[2] and $ARGV[2] =~ /^(--)??abs(olute)??$/ ) {
+ &send_mplayer_cmd("$parameter $ARGV[1] 1");
+ shift @ARGV;
+ shift @ARGV;
+ }
+ else {
+ &send_mplayer_cmd("$parameter $ARGV[1] 0");
+ shift @ARGV
+ }
+ }
+ else {
+ warn "WARN: $ARGV[0] needs at least numerica argument. Ignoring\n";
+ }
+ }
+
+# --next
+ elsif ( $ARGV[0] =~ /^((--)??next|-n)$/ ) {
+ &send_mplayer_cmd('seek 100 1');
+ }
+
+# --version
+ elsif ( $ARGV[0] =~ /^(--)??version$/ ) {
+ print "$playd_name v$playd_version\n";
+ }
+
+# --switch-audio
+ elsif ( $ARGV[0] =~ /^(--)??sw(itch)??-audio$/ ) {
+ &send_mplayer_cmd('switch_audio');
+ }
+
+# --switch-subtitle
+ elsif ( $ARGV[0] =~ /^(--)??(switch-substitle|sw-sub)$/ ) {
+ &send_mplayer_cmd('sub_select');
+ }
+
+# --cmd
+ elsif ( $ARGV[0] =~ /^(--)??cmd$/ ) {
+ if ( defined $ARGV[1] ) {
+ &send_mplayer_cmd($ARGV[1]);
+ shift @ARGV;
+ }
+ else {
+ warn "WARN: $ARGV[0] need option to be passed to mplayer. Ignoring\n";
+ warn "WANR: read http://www.mplayerhq.hu/DOCS/tech/slave.txt\n";
+ }
+ }
+
+# --pause
+ elsif ( $ARGV[0] =~ /^((--)??pause|-z)$/ ) {
+ &send_mplayer_cmd('pause');
+ }
+
+# --again
+ elsif ( $ARGV[0] =~ /^((--)??again|-A)$/ ) {
+ &send_mplayer_cmd('seek 0 1');
+ }
+
+# --noscheck
+ elsif ( $ARGV[0] =~ /^(--)??nocheck$/ ) {
+ if ( defined $ARGV[1] and -f $ARGV[1] ) {
+ &add_to_playlist($ARGV[1]);
+ shift @ARGV;
+ }
+ else {
+ warn "WARN: '$ARGV[1]' is not a file. Ignoring\n";
+ }
+ }
+
+# STREAMS
+ elsif ( $ARGV[0] =~ /:\/\// ) {
+ &start;
+ &send_mplayer_cmd("loadfile $ARGV[0] $playd_append");
+ }
+
+# --file
+# ANYTHING ELSE
+ else {
+ shift @ARGV if ( defined $ARGV[1] and $ARGV[0] =~ /^((--)??file|-f)$/ );
+ my $src = abs_path($ARGV[0]);
+ if ( -f $src ) {
+ my @tmp = &playable($src);
+ &add_to_playlist($tmp[0]) if (defined $tmp[0]);
+ }
+ elsif ( -d $src ) {
+ &start;
+ &mk_playlist($src);
+ if ( $playd_append ) {
+ open(TMP_PLAYLIST, '<', $playd_tmp_playlist) or die "ERR: can't open file '$playd_tmp_playlist' for reading.\n$!\n";
+ open(PLAYLIST, '>>', $playd_playlist) or die "ERR: can't open file '$playd_playlist' for writing.\n$!\n";
+ print PLAYLIST <TMP_PLAYLIST>;
+ close TMP_PLAYLIST;
+ close PLAYLIST;
+
+ &send_mplayer_cmd("loadlist '$playd_tmp_playlist' 1");
+ unlink $playd_tmp_playlist or die "ERR: can't delete file '$playd_tmp_playlist'.\n$!\n";
+ }
+ else {
+ unlink $playd_playlist if ( -f $playd_playlist );
+ rename ($playd_tmp_playlist, $playd_playlist) or die "ERR: $!\n";
+ &send_mplayer_cmd("loadlist '$playd_playlist' 0");
+ }
+ $playd_append = 1;
+
+ }
+ else {
+ warn "WARN: '$ARGV[0]' not a file/directory. Ignoring\n";
+ }
+ }
+
+ shift @ARGV;
+ }
+ exit;
+}
+
+sub send_mplayer_cmd {
+##############################
+# Send command to mplayer pipe
+##############################
+ if ( &get_mplayer_pid ) {
+ open (PIPE, '>>', $playd_fifo) or die "ERR: can't open '$playd_fifo':\n$!\n";
+ foreach my $item (@_) {
+ print PIPE "$item\n";
+ sleep 1;
+ }
+ close PIPE;
+ }
+ else { die "ERR: playd not started. Run:\n$playd_name start\n"; }
+}
+
+sub add_to_playlist {
+##############################
+# add items to playlist
+# nothing will be checked, check should happen earlier
+##############################
+ &start;
+ unless ( $playd_append ) {
+ unlink $playd_playlist if ( -f $playd_playlist );
+ }
+ open (PLAYLIST, '>>', $playd_playlist) or die "ERR: can't open '$playd_playlist':\n$!\n";
+
+ foreach my $item (@_) {
+ &send_mplayer_cmd("loadfile '$item' $playd_append");
+ print PLAYLIST "$item\n";
+ $playd_append = 1;
+ }
+ close PLAYLIST;
+}
+
+sub help () {
+##############################
+# desplays help
+##############################
+ print << "EOF"
+
+ $playd_name\tv$playd_version
+ by: killasmurf86
+ e-mail: killasmurf86\@gmail.com
+ homepage: http://code.google.com/p/playd/
+
+ $playd_name v$playd_version is a rewrite of playd.sh Bourne Shell script in perl.
+ It controls mplayer daemon via pipe. It's easy to use and implement in
+ other apps (In FVWM2 menu for example).
+
+ I wrote playd.sh when I was learning Bourne Shell. Now I'm learning Perl and
+ I think this is good script to practice what I read in book.
+
+ Hopefully this version will be more portable than playd.sh version :D
+
+EOF
+}
+
+sub get_mplayer_pid () {
+##############################
+# chech if playd is running, remove lock if not
+# returns GID if playd is running, return 0 if not or GIDS don't match
+##############################
+ if ( -f $playd_lock ) {
+ open (PIDFILE, '<', $playd_lock) or return 0;
+ my $gid = <PIDFILE>;
+ chomp $gid;
+ close PIDFILE;
+
+ my $pid = `pgrep -g $gid -n mplayer`;
+ chomp $pid;
+ return $pid if (defined $pid and $pid);
+
+ unlink $playd_lock if ( -f $playd_lock );
+ }
+ return 0;
+}
+
+sub list {
+##############################
+# lists current playlist
+# if $_[0] > 0 , then list files including full path
+# otherwhise $_[0] must be 0
+##############################
+ open (PLAYLIST, '<', $playd_playlist) or die "ERR: can't open file '$playd_playlist' for reading.\n$!\n";
+ my $i = 1;
+ while (my $playlist_item = <PLAYLIST>) {
+ # if nessacery remove file path
+ $playlist_item =~ s/.*?\///g unless ( $_[0] );
+
+ print "$i) $playlist_item";
+ $i++;
+ }
+ close PLAYLIST;
+}
+
+sub start () {
+##############################
+# start mplayer in slave mode
+##############################
+ unless ( &get_mplayer_pid ) {
+ my $mplayer_cmd;
+ unless ( $playd_novid ) {
+ $mplayer_cmd = "$playd_mplayer_cmd $playd_mplayer_user_options";
+ }
+ else {
+ $mplayer_cmd = "$playd_mplayer_no_video_cmd $playd_mplayer_user_options";
+ }
+
+ open(PIDFILE, '>', $playd_lock) or die "ERR: can't open '$playd_lock' for writing.\n$!\n";
+ my $gid = getpgrp(0);
+ print PIDFILE "$gid\n";
+ close PIDFILE;
+
+ my $dir = getcwd;
+ chdir rootdir;
+
+ unless ( $playd_console ) {
+ system("$mplayer_cmd > /dev/null 2> /dev/null &");
+ sleep 1;
+ }
+ else {
+ my $pid;
+ FORK: {
+ if ( $pid = fork ) {
+ chdir $dir;
+ return;
+ }
+ elsif ( defined $pid ) {
+ system($mplayer_cmd);
+ unlink $playd_lock if ( -f $playd_lock );
+ exit;
+ }
+ elsif ( $! == EAGAIN ) {
+ sleep 5;
+ redo FORK;
+ }
+ else {
+ unlink $playd_lock if ( -f $playd_lock );
+ die "ERR: failed to fork\n";
+ }
+ }
+ }
+
+ chdir $dir;
+ }
+}
+
+sub quit () {
+##############################
+# quit mplayer in slave mode
+##############################
+ my $pid = &get_mplayer_pid;
+ if ( $pid ) {
+ &send_mplayer_cmd('quit');
+ sleep 1;
+ if ( kill(0, $pid) ) {
+ kill 3, -$pid;
+ sleep 1;
+ if ( kill(0, $pid) ) {
+ kill 9, -$pid;
+ sleep 1;
+ die "ERR: can't kill mplayer. PID: $pid\n" unless ( kill(0, $pid) );
+ }
+ }
+ unlink $playd_lock if ( -f $playd_lock );
+ }
+}
+
+sub mk_playlist {
+##############################
+# make playlist form all files in dir and subdirs
+# arg[0 .. n] = absolute path to files/dirs
+##############################
+ my @file_list;
+ my @new_file_list;
+ foreach my $item (@_) {
+ if ( -f $item ) {
+ push(@file_list, "$item\n");
+ } elsif ( -d $item ) {
+ opendir(CURRENT_DIR, $item) or die "ERR: can't read dircetory: '$item'.\n$1\n";
+ my @content = readdir CURRENT_DIR;
+ closedir(CURRENT_DIR);
+ foreach my $i (2 .. $#content) {
+ $content[$i] = $item . "/" . $content[$i];
+ push(@new_file_list, $content[$i]);
+ }
+ }
+ }
+
+ open (LIST, '>>', $playd_tmp_playlist) or die "ERR: can't open file '$playd_tmp_playlist' for writing.\n$!\n";
+ print LIST &playable(sort @file_list);
+ close LIST;
+ &mk_playlist(@new_file_list) if ( @new_file_list );
+}
+
+sub playable () {
+##############################
+# return arry with playable files
+# input arry of file name or scalar with file name
+# file names, may end with \n
+##############################
+ my @playable_list;
+ foreach my $item (@_) {
+ push(@playable_list, $item)
+ if ( $item =~ /\.(mp3|flac|og[ga]|aac|wav|wma|aif[cf]??|m4[abpr]|mp[21a]|mpga|mid[i]??|mka|avi|mkv|mpf|mp4|wmv|vob|3gp|mov|d[i]??vx|og[mv])(\n)??$/i
+ or $ft->checktype_filename($item) =~ /^(audio|video)/ );
+ }
+ return @playable_list;
+}
+
diff -rNu playd2.bak/pkg-descr playd2/pkg-descr
--- playd2.bak/pkg-descr 2009-07-21 15:32:06.000000000 +0300
+++ playd2/pkg-descr 2009-12-15 08:56:55.595568350 +0200
@@ -4,7 +4,7 @@
player because playd supports playlists. It is easy to integrate
playd into a window manager menu (e.g. FVWM).
-WWW: http://code.google.com/p/playd/
+WWW: http://github.com/killasmurf86/playd
-- Aldis Berjoza
<killasmurf86 at gmail.com>
--- playd2.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list