How to scramble a playlist ?
Lothar Behrens
lothar.behrens at lollisoft.de
Tue Jan 20 23:53:59 CET 2009
Great,
that works. Now I have a random jukebox with just one click (with a
desktop file).
Lothar
Here is my script to get it working onto my bluetooth device:
#!/bin/sh
killall -SIGQUIT mplayer
/home/root/setup-bluetooth-audio.sh
rm playlist-sorted.m3u
rm playlist.m3u
find /media/card/Musik -name "*.mp3" > /home/root/playlist-sorted.m3u
/home/root/scramble.py /home/root/playlist-sorted.m3u > /home/root/
playlist.m3u
mplayer -ao alsa:device=bluetooth -playlist /home/root/playlist.m3u &
#mplayer -ao alsa:device=bluetooth http://yp.shoutcast.com/sbin/tunein-station.pls?id=2408
sleep 3
renice -19 `ps ax | grep mplayer | grep -Ev "grep|Unknown" | awk --
'BEGIN {}{ print $1;}'`
setup-bluetooth-audio.sh:
#!/bin/sh
# Your device
export DEVICE=XX:XX:XX:XX:XX:XX
/etc/init.d/bluetooth stop
/etc/init.d/bluetooth start
sleep 1
passkey-agent --default 0000 &
sleep 1
echo Create bonding
dbus-send --system --type=method_call --print-reply --dest=org.bluez /
org/bluez/hci0 org.bluez.Adapter.CreateBonding string
sleep 1
echo Activating service audio
dbus-send --system --print-reply --dest=org.bluez /org/bluez
org.bluez.Manager.ActivateService string:audio
sleep 1
echo Creating device
dbus-send --system --type=method_call --print-reply --dest=org.bluez /
org/bluez/audio org.bluez.audio.Manager.CreateDevice
sleep 1
echo Connecting sink
dbus-send --system --type=method_call --print-reply --dest=org.bluez "/
org/bluez/audio/device0" org.bluez.audio.Sink.Connec
Am 20.01.2009 um 22:09 schrieb eric at ericanddebbie.com:
> Here's a way to do it in python:
>
> #!/usr/bin/env python
> import sys, random
> filename = sys.argv[1]
> a = open(filename).read().strip().split("\n")
> random.shuffle(a)
> for i in a:
> print i
>
>
> If you're not famililar with shell stuff:
>
> Save that to a file like "scramble" and then do:
> python scramble myfile
>
> You can just type "scramble myfile" after you've done
> "chmod +x scramble"
>
> Probably you want to redirect the list into a file:
> python scramble myplaylist.txt > /tmp/shuffledplaylist.txt
> or you can add python code to accept another argument for an
> outfilename and write the file -- with a check to make sure you're not
> overwriting an existing file (don't want you to overwrite your
> playlist on accident :)
>
> Eric
>
> _______________________________________________
> Openmoko community mailing list
> community at lists.openmoko.org
> http://lists.openmoko.org/mailman/listinfo/community
>
-- | Rapid Prototyping | XSLT Codegeneration | http://www.lollisoft.de
Lothar Behrens
Heinrich-Scheufelen-Platz 2
73252 Lenningen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openmoko.org/pipermail/community/attachments/20090120/cb8410a0/attachment.htm
More information about the community
mailing list