Rate Today's Posts, 11/22/2009 - Sunday

Search:

Please Sign In or Register  |  Set as Homepage

iTunes Remote Control   Rating: -68 from 100 votes    Views: 1,787

Submitted By: Noah on 1/8/2007. (  |  Share  |  Clikk It! )   
← Previous Random Next →


Link: http://www.macdevcenter.com/pub/a/mac/2005/03/01/itunes_remote.html
If you own an Airport Express, you know that it can be inconvenient to travel back and forth to iTunes in order to please the masses at parties. You might also find paying an additional 50 percent (of the price of your Express) to buy a remote control unacceptable. Not to worry, you can build your own remote control using your web-enabled cell phone and some of the magic built in to Mac OS X. The only catches are that it's free, has a range that reaches farther than you'll ever need, and is as customizable as you like. But wait a minute; those are good things!
Putting Together the Pieces

Building your own cell phone remote control for iTunes (or any other application for that matter) isn't difficult if you have the right tools and follow a few basic steps. Assuming you have a cell phone that can surf the web and a working Internet connection, the only other requirement is some brain power. Here's the recipe:

* Get the Apache (httpd) Web Server up and running
* Augment Apache to serve Wireless Application Protocol (WAP) content
* Write a daemon that controls iTunes via AppleScripts
* Write Common Gateway Interface (CGI) scripts to serve the WAP content and pass messages to the daemon

Setting up an iTunes remote control not only allows you to DJ parties without looking like a computer nerd, it also allows you to tap other cool possibilities like adding a wireless snooze feature to your iTunes alarm clock, or surprising family members at home with pre-recorded messages (while you sit at work and chuckle quietly).
Setting up Apache

Kevin Hemenway has already written a very good series on setting up Apache. You can get to the whole series by starting with his bio, or start directly with Part 1 of the series here. Our steps in setting up Apache are extremely minimal, but the much fuller context is there if you want it.
Personal Web Sharing in System Preferences Starting up Apache in OS X is as simple as checking a box in System Preferences

To get started, open up the "Sharing" folder in System Preferences and enable "Personal Web Sharing." After this change, you should immediately be able to type http://localhost into your browser and see one of Apache's localized startup pages being displayed from /Library/WebServer/Documents. The name localhost has the corresponding IP address of 127.0.0.1, but you could also get to this same page with the IP address assigned to your machine by your default gateway, which probably pulls double duty as your firewall and is more commonly referred to as your router. Typing ifconfig in Terminal gives you the internal IP address that identifies your machine on your home network.
Typing ifconfig in Terminal for internal IP address If you have a home network behind a firewall or router, typing "ifconfig" at a Terminal prompt gives you your IP address internal to your home network.

To be able to access your home web server from anywhere in the world (including cell phones), the firewall protecting your web server needs to allow incoming traffic on port 80, and you need to know your external IP address that identifies your server to the internet at large. For example, my 2Wire Home Portal allows me to open a control panel in my web browser to accomplish these things. Most routers follow suit; check your manual for more info or search the web for your specific model. If you have a dial-up connection, your mileage may vary depending upon your Internet Service Provider.

Once you've opened up port 80, you should be able to get the default Apache page by typing your external IP address into your browser. There are two primary considerations to address at this point: 1) security concerns and 2) IP address changes because of Dynamic Host Configuration Protocol (DHCP). For security concerns, stay on top of your updates, check out this primer, and spend some time surfing the web on web server security. You can potentially spare yourself many problems by closing the port whenever it's not being used for extended time periods.

Before you work around the potential DHCP issue, determine first whether or not it is actually a problem. It could be the case that your IP address doesn't change as often as you'd think. You can keep an eye on it using your router's control panel to see what the trend appears to be, or call your ISP and ask them about their particular policy. If you find you have a particular IP address for hours at a time and use your iTunes remote control only occasionally, you might want to look it up when you need it instead of working around it. If you decide to do a workaround, you can check here for a tutorial that shows you how. The workaround addresses a .Mac audience, but works equally as well with any constant point of entry (such as one of the many free hosting services). For our iTunes remote control, I'll assume you're just using your external IP address directly.
Getting Apache to Serve WAP Content

From looking at the earlier link to WAP, you know that the WAP protocol is a standard for serving web content to small wireless devices that have low bandwidth and small viewing areas--like our cell phones. To get Apache to serve WAP content, its configuration file must be slightly modified. Open up /etc/httpd/httpd.conf in Terminal by with root level permissions by using sudo and add the two snippets of content below. Back up this file before modifying it just in case disaster occurs. For each snippet, I've given a few lines of context to help you find a good insertion location.

Here is the first snippet that allows Apache to recognize particular MIME types associated with WAP based on file extension:

#
# AddType allows you to tweak mime.types without
# actually editing it, or to
# make certain files to be certain types.
#
AddType application/x-tar .tgz

####################################################
#Added 25 Feb 05 -MR
#This tells Apache to serve these mime types
#to browsers when they ask for them based on
#file extension. Apache assumes the browser knows
#that to do with these types if it asks for them
####################################################
#WML/WAP types
AddType text/vnd.wap.wml .wml
AddType application/vnd.wap.wmlc .wmlc
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlscriptc .wmlsc
AddType image/vnd.wap.wbmp .wbmp
####################################################

This second snippet is for convenience. It changes the default file Apache serves when given a request for content in the root directory.


###########################################
#Added 25 Feb 05 -MR
#Replace index.html with /cgi-bin/index.pl
#to change the default page served
###########################################
#DirectoryIndex index.html
DirectoryIndex /cgi-bin/index.pl


Important: these changes won't reflect until you restart Apache by stopping and starting "Personal Web Sharing" from System preferences.

You should now be able to verify that Apache serves WAP content. To see for yourself, save the following WML file as /Library/WebServer/Documents/hello.wml


"-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">


<card title="Hello World">

Hello World


card>


Your browser doesn't expect to receive WAP content, so you need to use your cell phone or a WAP emulator such as Wapsilon to view the content. In your cell phone or an emulator, enter http://your-ip-address/hello.wml and you should get the infamous "Hello World" message. If you try to open this page in your computer's web browser, it won't display it because it doesn't expect this MIME type.
Solicitation to Download WAP
Your Mac's web browser doesn't expect WAP content, so it defaults to a download option. Your cell phone and other WAP enabled-devices, however, do expect this type of content and happily display them.

Tags: itunes  mac  os x  remote control  
Link to this:

* copy and paste the above text into your site to link to this post.


If this post contains copyrighted or otherwise illegal material please let us know by clicking here.
If this post contains adult material please click here so we can place it in the appropriate section.

Comments and Reviews   (Average Member Review: average stars)


Your Ad Here

How would you rate this post?  

Review Title:  

Review:


  I am over the age of 13.



Add Stuff

Share this page

New:

dry flowerdry flower
more                                                                                                                                                                     

Coosh Crash Test - neckbreaking stunt!Coosh Crash Test - neckbreaking stunt!
Massive Monkees crash test coosh - see the result! See the Massive Monkees try everything they can to shake off the coosh. more

Sponsor

Your Ad Here

Popular:

Rate my Cam DanceRate my Cam Dance
Wannabe dancers get video exposure – RateMyCamDance.com, a new online video website launches today, focussing on the vir... more

1942 Job Advertisement1942 Job Advertisement
This is no picnic Working and living conditions on this job are as difficult as those encountered on any construction job e... more

Recent History

Random Links From Our Friends

Bored?  Check Out Today's Hotlinks

RateMyEverything on Reddit

RateMyEverything on Digg

Activity

1869 People Online