For systems using udev I wrote two scripts which allows to austostart a
CD when the CD inserted into the drive.
The great thing with udev is, that udev supplies the number of tracks.
The first is a very simple rule for udev.
It just tells udev to run a script whenever there was a change in the
status of the cddrive.
create a file named 20-cdrom-media-change.rules in /etc/udev/rules.d/
put the following in the file:
Code:
--------------------
KERNEL=="sr?", SUBSYSTEM=="block", ACTION=="change",
RUN+="/usr/bin/cd_media_changed.sh"
--------------------
This will tell udev to call the script /usr/bin/cd_media_changed.sh
If you have more than one drive, adjust sr? to what your drive used to
play music actually is. i.e. sr0 or sr1 or ...
The second script will create a playlist and tell the server to use this
playlist to play.
create a file named cd_media_changed.sh in /usr/bin/ and make it
executable.
Place the following content into the file and
*_adjust_the_settings_to_your_own_needs_as_stated_in_the_code._This_is_important!_*.
Code:
--------------------
#! /bin/sh
# adjust this to your needs
server_ip="127.0.0.1"
server_port="9000" # on my qnap this is 9001
# this is the path to your playlistfolder as specified
# in the settings of squeezbox server, logitech media server
# + the filename of the playlist (name it whatever you want)
playlist="/home/squeezebox/playlists/current_cd.m3u"
#>>>>>>>>>>>>>> IMPORTANT <<<<<<<<<<<<<<<
# commands need to be urlencoded.
# use http://meyerweb.com/eric/tools/dencoder/
# or replace any = with %3D
# & with %26
# / with %2F
#
# urlencoded path to playlist
playlist_enc="%2Fhome%2Fsqueezebox%2Fplaylists%2Fcurrent_cd.m3u"
# urlencoded for
p0=playlist&p1=play&p2=/home/squeezebox/playlists/current_cd.m3u
cmd_play_enc="p0%3Dplaylist%26p1%3Dplay%26p2%3D"$playlist_enc
# urlencoded for p0=playlist&p2=clear
cmd_clear_enc="p0%3Dplaylist%26p1%3Dclear"
# compute complete url
server_url="http://"$server_ip":"$server_port"/status.html?"
# check if cd has been inserted or ejected
if [ "$ID_CDROM_MEDIA_CD" == "1" ]
then
# start new playlistfile
textout="#CURTRACK 0\n"
textout=$textout"#EXTM3U\n"
# create one entry for each track
for ((i=1;i<=$ID_CDROM_MEDIA_TRACK_COUNT;i++))
do
# write out #EXTURL:cdplay://1 ...
textout=$textout"#EXTURL:cdplay://$i\n"
# write out #EXTINF:-1,Track 1 ...
textout=$textout"#EXTINF:-1,Track $i\n"
# write out cdplay://1 ...
textout=$textout"cdplay://$i\n"
done
# write playlist
echo -e $textout > $playlist
# tell server to use and play the playlist
wget -t1 -q -O- $server_url$cmd_play_enc >> /dev/null
else # EJECTED
#clear playlist - stop playing
wget -t1 -q -O- $server_url$cmd_clear_enc >> /dev/null
# delete playlist
rm $playlist
fi
--------------------
Unfortunately I have not found out yet how to tell SB/LMS to display
"Track 1","Track 2","...." instead of "Unknown Track".
On my Squeezeplay it also displays "Track 1 of 12" even if Track 7 is
played.
If someone has a solution for this, please post it.
Have fun.
------------------------------------------------------------------------
Viator's Profile: http://forums.slimdevices.com/member.php?userid=63789
View this thread: http://forums.slimdevices.com/showthread.php?t=47288
_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins