Chris Bennett wrote:
well, on my machine, mplayer does get it's last aucat volume back.
that is, if I start mplayer then set it's aucat volume to 90, then
quit mplayer and start it again later, it's aucat volume is 90.
this works through playlists too.  mplayer's internal volume,
however, gets reset both when stopping/starting and when changing
songs in a playlist.  mplayer's internal volume is what is displayed
by mplayer.

if you are manipulating aucat volume because you have no hardware
controls, you might find the nmixer program from the mp3blaster
package useful.

Just tried nmixer, but it has same problem as aucatvol.
Only works after starting mplayer.
So that isn't a better solution in my case, since I have a "clearer" set of scripts for aucatvol.

Worth a try, though

FWIW, I may as well share the scripts I use
These don't work perfectly, sometimes aucat keeps its volume.
I don't know why, using u or d from volumechanger restores order.

For changing volume, but keeping a record of current setting:

in .profile:
pgrep -x aucat || (aucat -l -v 127 && echo '127' > /home/chris/current_vol)

$ cat volumechanger
#!/bin/sh

# script to change volume with aucatvol.
# file current_vol marks current volume level as of last change.

# current_vol will not have correct volume level after reboot until
# fully dropped to zero or raised to 127 or volume set to a value with -s option

USAGE="Usage: $0 [-u | -d | -e | -s (0-127)] to raise or lower volume, see volume or set volume exactly"
CURR_VOL=`cat /home/chris/current_vol`

case "$1" in
       -u) RAISE=`expr $CURR_VOL + 8`
           if [ $RAISE -gt 127 ] ; then
               RAISE=127
           fi
           `/home/chris101/aucatvol $RAISE`
           echo "$RAISE"  > /home/chris/current_vol
           echo "$CURR_VOL -> $RAISE" ;;
       -d) DROP=`expr $CURR_VOL - 8`
           if [ $DROP -lt 0 ] ; then
               DROP=0
           fi
           `/home/chris101/aucatvol $DROP`
           echo "$DROP"  > /home/chris/current_vol
           echo "$CURR_VOL -> $DROP" ;;
       -e) echo "Current Volume = $CURR_VOL"
           exit 0 ;;
       -s) if [ $2 ] && [ $2 -ge 0 ] && [ $2 -le 127 ] ; then
               `/home/chris101/aucatvol $2`
               echo "$2" > /home/chris/current_vol
               NEW_VOL=`cat /home/chris/current_vol`
               echo "$CURR_VOL -> $NEW_VOL"
               exit 0
           else
               echo "Error: Set value must be 0-127"
               exit 1
           fi ;;
       *) echo "$USAGE"
          exit 1 ;;
esac


--------------
for mplayer

perl version

#!/usr/bin/perl
#
#       mplayer shuffle playlist and adjust volume
#

use warnings;
use strict;

use Errno qw (EAGAIN);

unless ($ARGV[0]) {
       print "Please enter a playlist\n";
open(my $fh, "-|", "find", "/home/chris", "-name", "*\.pls" ) || die("Unable to open find pipe: $!");
       while (<$fh>) {
               print;
       }
       close($fh);
       exit 1;
}
my $pid;

FORK: {
       if ($pid = fork) {
               exec "mplayer -shuffle -playlist $ARGV[0]";
       }
       elsif (defined $pid) {
               system "sleep .3";
               exec "/home/chris/volumechanger -s 31";
       }
}

exit 0;

or shell (I prefer perl, but did this as an exercise)

#!/bin/bash

for ((i=0;i<4;i++)); do
 sleep .1
/home/chris/volumechanger -s 31
done &

mplayer "$@"

--
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
  -- Robert Heinlein

Reply via email to