You are not logged in.
Pages: 1
Mpd has this new mode where it removes played songs from playlist. I thought this is perfect for dynamic playlist support since all you need to do is add 10 random songs to playlist and after each played song add another one.
In an ideal world this would be done in C because libmpdclient does support the idle protocol of mpd (detects track changes and stuff)
Well this is no ideal world and C is above my knowledge
So i try to do it in bash and have to realise i am even to stupid to do it this way.
i have the comand that actually adds songs to the playlist:
mpc clear && mpc listall | sort -R | head -n 10 | mpc add && mpc play
I also have the command that adds another song if song changes:
mpc listall | sort -R | head -n 1 | mpc add
what i need now is a function that compares the output of "mpc | head -n 1" every couple of seconds and if it changes it issues this last command...
Or maybe someone wants the same thing and does it using C
He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.
Douglas Adams
Offline
#!/bin/bash
TIMEOUT=1
ORIG=""
while(true); do
NOW=$(mpc | head -n 1)
if [[ $ORIG =~ $NOW ]]
then
echo "Song still playing";
else
echo "Song changed to: \"$NOW\"";
ORIG=$NOW;
fi
sleep $TIMEOUT
done
Last edited by Wra!th (2009-04-25 10:36:19)
MacGregor DESPITE THEM!
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Offline
thank you very much.. its working perfecly!
He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.
Douglas Adams
Offline
Pages: 1