Package: randomplay
Version: 0.49
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sometimes it happens to me that a new song starts, and only then I
realize that I haven't listend to the previous one. That's why I
thought about a back/previous/replay keystroke action.

Attached is a patch that implements the basic functionality of going
back once to the previous song. I'm not sure if it's the perfect
solution, but maybe you like it anyway or take it as an inspiration
for something similar.

Regards,
gregor

- -- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15.200601212149
Locale: LANG=C, [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages randomplay depends on:
ii  libdate-calc-perl             5.4-4      Perl library for accessing dates
ii  libmp3-info-perl              1.13-1     Perl MP3::Info - Manipulate / fetc
ii  libogg-vorbis-header-perl     0.03-1     perl interface to Ogg Vorbis infor
ii  libterm-readkey-perl          2.30-2     A perl module for simple terminal 
ii  perl                          5.8.7-10   Larry Wall's Practical Extraction 

Versions of packages randomplay recommends:
ii  mpg321                        0.2.10.3   A Free command-line mp3 player, co
ii  vorbis-tools                  1.1.1-3    several Ogg Vorbis tools

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD49JwOzKYnQDzz+QRAmUdAJ9MsYCS8UA03wHLb81ZlY6bZ7YJ8QCgqIc2
M8x4VrQoCc15eoQguVliOTo=
=Da3K
-----END PGP SIGNATURE-----
--- randomplay  2005-12-09 22:43:54.000000000 +0100
+++ randomplay.replay   2006-02-03 22:48:38.000000000 +0100
@@ -52,2 +52,4 @@
 my $announce_song = "";
+my $previous_song = "";
+my $replay = 0;
 $announce_song = "osd_cat -p bottom -l 2 -A right -c white -d 5 -f 
'-etl-fixed-medium-r-*-*-24-*-*-*-*-*-*-*'" if ( -x "/usr/bin/osd_cat" || -x 
"/usr/local/bin/osd_cat" );
@@ -182,2 +184,3 @@
 $key{'next'} = "Nn" unless exists $key{'next'};
+$key{'replay'} = "Rr" unless exists $key{'replay'};
 $key{'quit'} = "Qq" unless exists $key{'quit'};
@@ -325,3 +328,6 @@
   last if $maxtime and time - $start_time > $maxtime; # finished playing 
specified number of seconds, stop playing
-  if ($weight_favorites) {                            # random weighting, we 
flip a coin but make it easier or harder to
+  if ($replay) {                                      # play last song again
+     $_ = $previous_song;
+     $replay = 0;
+  } elsif ($weight_favorites) {                       # random weighting, we 
flip a coin but make it easier or harder to
      $_ = "";                                         # get "heads" 
(rand(1)>0.5) based on the song's score
@@ -425,2 +431,6 @@
          &KillOrPausePlayer($pid);
+      } elsif ($key{'replay'} =~ /\Q$keystroke\E/) {
+         print "Replaying last song...\n" unless $quiet;
+         $replay = 1;
+         &KillOrPausePlayer($pid);
       } elsif ($key{'quit'} =~ /\Q$keystroke\E/) {
@@ -455,2 +465,3 @@
   }
+  $previous_song = $_ unless $replay; # remember song if $key{'replay'} not 
pressed
   next unless $remember;        # don't record this track in history if we are 
in 'noremember' mode
@@ -523,2 +534,4 @@
                                      (set with --key next=keystrokes)
+   r                                 replay last song
+                                     (set with --key replay=keystrokes)
    p                                 pause the playback (toggle)

Reply via email to