This is probably not of the most general interest these days, but it is useful to me.
I tried the script of Alex Schroeder, but it did not run for me (on OS X Lion, LMS 7.7 & iTunes 10.7). I got it to run by changing the path specification from file_id URL to POSIX path. I also had to restore code from Brad Mohr's earlier script for translating the POSIX path into "escaped" form. I also put in the possibility of specifying the player rather than controlling only the default player. I have tested it a few times, also running it from the iTunes script menu, and specifying different players. Seems to work OK now. I won't be able to help with details of its operation as I don't actually understand anything about applescript programming! Here is the script: --SlimPlay -- minor modifications of work of Alex Schroeder by F. Goodman --December 2012 -- SlimPlay -- by Alex Schroeder, [email protected] -- March 2008 -- by Brad Mohr, bmohr (AT) seanet (DOT) com -- 22 January 2003 -- This script is absolutely free and may be used by anyone for any purpose. -- Known Limitations: -- Currently only supports a single Squeezebox. -- Very little error checking -- edit these properties to match your setup. property squeezecenter_host : "localhost" -- URL or IP address of the SlimServer property squeezecenter_port : "9090" -- server port number for the command line interface, default is 9090 property player_id : " " -- MAC address of desired player; leave blank to use default or only player tell application "iTunes" set these_tracks to the selection of browser window 1 if these_tracks is {} then error "No tracks are selected in the front window." set should_play to false display dialog "What would you like to do with these tracks?" buttons {"Play", "Append", "Cancel"} default button 2 if the button returned of the result is not "Cancel" then if the button returned of the result is "Play" then set should_play to true set is_first_file to true repeat with a_track in these_tracks set carbon_filepath to the location of a_track set track_title to the name of a_track tell application "Finder" to set filepath to POSIX path of carbon_filepath set escaped_path to encode_text(filepath, true, false) of me if should_play then if is_first_file then playlist_play_track(escaped_path) of me set is_first_file to false else playlist_append_track(escaped_path) of me end if else playlist_append_track(escaped_path) of me end if end repeat if should_play then begin_playing() of me end if end if end tell on encode_text(this_text, encode_URL_A, encode_URL_B) set the standard_characters to "abcdefghijklmnopqrstuvwxyz0123456789" set the URL_A_chars to "$+!'/?;&@=#%><{}[]\"~`^\\|*" set the URL_B_chars to "().-_:" set the acceptable_characters to the standard_characters if encode_URL_A is false then ¬ set the acceptable_characters to the acceptable_characters & the URL_A_chars if encode_URL_B is false then ¬ set the acceptable_characters to the acceptable_characters & the URL_B_chars set the encoded_text to "" repeat with this_char in this_text if this_char is in the acceptable_characters then set the encoded_text to (the encoded_text & this_char) else set the encoded_text to (the encoded_text & encode_char(this_char)) as string end if end repeat return the encoded_text end encode_text -- this sub-routine is used to encode a character -- sample code from Apple -- (doesn't work right for utf8) on encode_char(this_char) set the ASCII_num to (the ASCII number this_char) set the hex_list to ¬ {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"} set x to item ((ASCII_num div 16) + 1) of the hex_list set y to item ((ASCII_num mod 16) + 1) of the hex_list return ("%" & x & y) as string end encode_char -- append the new track to the playlist on playlist_append_track(escapedTrackPath) send_command("playlist add " & escapedTrackPath) end playlist_append_track -- replace the existing playlist with the new track on playlist_play_track(escapedTrackPath) send_command("playlist play " & escapedTrackPath) end playlist_play_track -- tell the default (or only) server to begin playing on begin_playing() send_command("play") end begin_playing on send_command(command) tell application "Finder" set shell_command to "echo '" & player_id & command & "\\nexit' | /usr/bin/nc " & squeezecenter_host & " " & squeezecenter_port & "; exit 0" -- display dialog shell_command buttons {"Ok"} set result to do shell script shell_command -- display dialog result buttons {"Ok"} end tell end send_command ------------------------------------------------------------------------ fredgoodman's Profile: http://forums.slimdevices.com/member.php?userid=7616 View this thread: http://forums.slimdevices.com/showthread.php?t=8967
_______________________________________________ discuss mailing list [email protected] http://lists.slimdevices.com/mailman/listinfo/discuss
