Women in Technology

Hear us Roar



Article:
  Build an iTunes Remote Control
Subject:   I wrote this, And it doesn't work.
Date:   2005-03-20 15:49:46
From:   Cool6324
Response to: I wrote this, And it doesn't work.

I dont re-boot my system enough, but I do have a iBook that I carry, and I sometimes have to boot. But as long as it's running, I have no problem. I also noticed, that apon excuting the script file in terminal, it does freeze which may give the appearence that nothing is happining, but don't be fooled, the script has been executed!! And do not run it again, because that will cause actions to be repeated. Once the script is opened the terminal, the only way I can get ever thing working is to run this sudo chmod 777 /private/tmp/iTunesRemoteControl in terminal. That will do the trick. I have also added some commands(change album), which anyone can do, copy and paste the info in any if the xxx.pl file's.


#!/usr/bin/perl


system "echo 'XXXXX' > /tmp/iTunesRemoteControl";
system "chmod uga+rw /tmp/iTunesRemoteControl";


print "Content-type: text/vnd.wap.wml\n\n";


open MENU, "./menu" or die "'menu' not in current dir";
while (<MENU>) {print "$_";}
close MENU;


Define a varible where XXXXX is, and add it to the daemon


#!/bin/bash
##########################################################
#Matthew Russell -25 Feb 05
#Usage: prompt$./iTunesRemoteControlDaemon.scr &
#
#This simply reads a file and executes an AppleScript that
#controls iTunes based on its content.
#
#kill the daemon with script killRemoteDaemon.scr
##########################################################


############
#User Prefs
############
scriptDir="/Library/WebServer/CGI-Executables"
remoteCommand="/tmp/iTunesRemoteControl"
delay="1.0"



#############
#begin script
#############
while [ 1 ]; do


status=`cat $remoteCommand`


case $status in
"getlyrics") osascript $scriptDir/GoogleLyricSearch.scpt;;
"nextalbum") osascript $scriptDir/PlayNextAlbum.scpt;;
"open") osascript $scriptDir/open.scpt;;
"RandomTrack") osascript $scriptDir/RandomTrack.scpt;;
"Rewind") osascript $scriptDir/Rewind.scpt;;
"FastForward") osascript $scriptDir/FastForward.scpt;;
"MuteUnMute") osascript $scriptDir/MuteUnMute.scpt;;
"PlayPause") osascript $scriptDir/PlayPause.scpt;;
"VolumeDown") osascript $scriptDir/VolumeDown.scpt;;
"VolumeUp") osascript $scriptDir/VolumeUp.scpt;;
esac


echo "" > $remoteCommand
sleep $delay


done


As you can see I added some, pointing to the corresponding script.


I added one to open, change album, and even get Lyrics. The same concept can be used in all applications and you can just add to the existing daemon(I'm Guessing).


So in closing I've learned alot in two days, I think my "wapTunes" is ready to be shown off to my friends, at school.



Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Matthew Russell photo I wrote this, And it doesn't work.
    2005-03-20 16:24:11  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

    Glad you had fun with this. That's what it's all about!

    M.