=================================================================== RCS file: /cvs/mp3/daemon/playmp3s.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- mp3/daemon/playmp3s.pl 2007/02/08 18:13:33 1.5 +++ mp3/daemon/playmp3s.pl 2007/02/08 23:02:30 1.6 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $RedRiver: playmp3s.pl,v 1.4 2007/02/08 17:54:38 andrew Exp $ +# $RedRiver: playmp3s.pl,v 1.5 2007/02/08 18:13:33 andrew Exp $ ######################################################################## # PlayMP3.pl *** play's MP3s off a playlist using mp3play # @@ -19,6 +19,7 @@ my $err_log = $cfgs{errors} || "/var/log/playmp3s.log"; +my $Num_History = 0; Print_PlayLog("Beginning playtime\n\n"); @@ -74,16 +75,22 @@ Print_PlayLog("Playing: $filename . . .\n"); + my $player; + my $play = "$cfgs{basedir}$filename"; if (defined $filename && $filename =~ /\.mp3$/i) { - `$cfgs{mp3play} \"$cfgs{basedir}$filename\"`; + $player = $cfgs{mp3play}; } elsif ($filename =~ /\.ogg$/i) { - my $play = "$cfgs{basedir}$filename"; - $play =~ s/(\(|\)|&|"|'| |-)/\\$1/g; - print "\n\n$play\n\n"; - `$cfgs{oggplay} $play`; + $player = $cfgs{oggplay}; + #$play =~ s/(\(|\)|&|"|'| |-)/\\$1/g; } + if (not $player =~ s/\{\}/"$play"/g) { + $player .= ' "' . $play . '"'; + } + Print_PlayLog("$player\n"); + `$player`; + # my $kid = 0; # while ($kid ne -1 && ContinueRun()) { # while ($kid ne -1) { @@ -97,7 +104,7 @@ Print_PlayLog("Adding Last. . ."); delete ${ $Full_Playlist{list} }{$song}; - AddLast($filename, $cfgs{playedlist}, $cfgs{numhistory}, $cfgs{playedhtml}, $cfgs{addurl}); + AddLast($filename, $cfgs{playedlist}, $Num_History, $cfgs{playedhtml}, $cfgs{addurl}); Print_PlayLog("done\n"); } @@ -167,10 +174,17 @@ delete $Full_Playlist{list}; + my $list_size = 0; foreach my $song (@list) { + $list_size++; $Full_Playlist{list}{$song} = 1 unless (exists $played{$song}); } + my $history = int $list_size * 0.1; + if ($history) { + Print_PlayLog("New history is $history\n"); + $Num_History = $history; + } $Full_Playlist{last_mod} = $last_mod; } @@ -250,7 +264,7 @@ ####################################################################### # Prints a webpage with the previously played song -# AddLast($filename, $cfgs{playedlist}, $cfgs{numhistory}, $cfgs{playedhtml}, $cfgs{addurl}); +# AddLast($filename, $cfgs{playedlist}, $Num_History, $cfgs{playedhtml}, $cfgs{addurl}); sub AddLast { my $lastsong = shift; my $lastlist = shift; @@ -260,7 +274,7 @@ my @LIST = get_playlist($lastlist); unshift @LIST, $lastsong; - splice (@LIST, $history); + splice (@LIST, $history) if $history; save_playlist($lastlist,@LIST); DisplayPrevious($htmlfile, $addurl, @LIST); }