I know this is about a specific program (mplayer back-end); however it will be used to program a front-end so I hope it is still considered on-topic on Stack Overflow.
I want to run two mplayer slave instances which will be used to fade between different audio streams (webradio; smoothly change the channel). To do this, I set the "software volume" of mplayer so it will not affect the PCM output channel of the sound card but insert a software volume mixer to adjust the volume.
However, I encounter the following problem.
I start mplayer with the following command (can be tested on command-line):
mplayer -slave -idle -softvol
and send the following commands to mplayer:
loadfile <url>
set volume 0
it starts (for a short time) to play the file at 100% volume and then jumps to 0% volume. If I swap the two commands, mplayer tells me that I can't adjust the volume:
Failed to set property 'volume' to '0'.
ANS_ERROR=PROPERTY_UNAVAILABLE
Obviously, the audio filter isn't yet loaded / audio output not yet set up or something like that, so mplayer can't change the volume of a non-existing audio output.
Can I force mplayer to initialize everything in advance so that I can set the volume to 0%, load the file and then increase the volume to fade in the playback?
I already checked whether I can set the volume after playing some file (e.g. a silent dummy file); mplayer complains with the same error. For now, the only option I can think of is to start such a dummy file, adjust the volume, stop the dummy file, load the correct file to be played, and it will start with the volume just set. But I can't believe this is the best option.
I solved the problem by myself: While I tried to follow this guide, -af volume=0
didn't help. However, there also is a -volume 0
command line option which worked for me:
mplayer -slave -idle -softvol -volume 0
I have found this working perfect @ my home player
important, while volume setting: the 1 in 'echo "volume $i 1 "' otherwise no change in vol.
mkfifo /tmp/mi1 and /tmp/mi2 and set the $url1 and $url2 to your radiostreamurls prior to this
mplayer -softvol -slave -input file=/tmp/mi1 $url1 &>/dev/null & mplayer -softvol -slave -input file=/tmp/mi2 $url2 & for ((i=1; i<=100; i+=1)); do sleep 0.25; echo "volume $(( 100 - $i )) 1 ">/tmp/mi1; sleep 0.25 ; echo "volume $i 1 ">/tmp/mi2 ; done ; (sleep 5 ; echo quit >/tmp/mi1 ;echo quit >/tmp/mi2)&
happy listening
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With