image
image

|


Go Back   macosx.com > Mac Help Forums > HOWTO & FAQs

Reply
 
Thread Tools
  #1  
Old July 20th, 2005, 01:58 PM
MacTechie17
 
Join Date: Jul 2005
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
slooksterpsv is on a distinguished road
[HOW-TO] Control iTunes Remotely via Web Browser (MAC ONLY)

HOW-TO:
NOTE: YOU CAN USE ANY BROWSER ON ANY OS TO CONTROL iTunes BUT YOU CAN ONLY SET IT UP ON MAC - THIS WILL NOT WORK ON WINDOWS CAUSE YOU DON'T HAVE THE UNIX COMMANDS TO CONTROL IT.
WARNING: THIS MAKES SECURITY RISKS ON YOUR COMPUTER!
Step 1 - Modify httpd.conf
1) Open Terminal and locate to the patch /etc/httpd type in sudo pico httpd.conf
A lot of these things you'll have to find within httpd.conf - but after you do one, it'll be next down the line:

Take the # off of LoadModule php4_module libexec/httpd/libphp4.so
Take the # off of AddModule mod_php4.c
Find:
#
User www
Group www

and change it to
#
User your_short_username #mine is sbarn
Group staff

Find:
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>

Add a space after index.html and add index.php
Hit Control O to bring up the save file at the bottom, hit enter then control X to exit.

Next type:
sudo apachectl graceful

Now for Step 2 - Creating the PHP File
2)I'm changing this site so you guys can make it just that awesome, here's the code that you place in the index.php - I cut the image from iTunes via Command + Shift + 4 - here's the entire code:
PHP Code:
<html>
<head>
<!-- < $url = "index.html";
<echo "<META HTTP-EQUIV=refresh content=0;URL=$url>" > //-->
<title>Remote Control iTunes</title>
</head>
<body>
<?
$q 
$_GET['q'];
switch (
$q)
{
case 
"";
//echo "You need to send me a command, then I shall execute it";
break;
case 
"play";
exec("osascript -e 'tell app \"iTunes\" to play'");
//echo "Playing";
break;

case 
"pause";
exec("osascript -e 'tell app \"iTunes\" to pause'");
//echo "Pausing";
break;

case 
"playpause";
exec("osascript -e 'tell app \"iTunes\" to playpause'");
//echo "Toggling Play";
break;

case 
"next";
exec("osascript -e 'tell app \"iTunes\" to next track'");
//echo "Next Track";
break;

case 
"prev";
exec("osascript -e 'tell app \"iTunes\" to previous track'");
//echo "Previous Track";
break;

case 
"louder";
exec("osascript -e 'tell app \"iTunes\" to set sound volume to sound volume + 5'");
//echo "Turning Up the Volume";
break;

case 
"quieter";
exec("osascript -e 'tell app \"iTunes\" to set sound volume to sound volume - 5'");
//echo "Turning Down the Volume";
break;
case 
"open";
exec("osascript -e 'tell app \"iTunes\" to open'");
break;
case 
"mute";
mutev();
//echo "Muting the Volume";
break;
}


function 
mutev()
{
//echo "start mute function<br>";

$data file_get_contents("/Library/WebServer/Documents/volume.txt");

$logfile fopen("/Library/WebServer/Documents/volume.txt",'w');

$oldvolume exec("osascript -e 'tell app \"iTunes\" to sound volume'");

//echo "volume data:$data:<br>";
if ($data == "x")
{
fwrite($logfile,$oldvolume);
exec("osascript -e 'tell app \"iTunes\" to set sound volume to 0'");
}
else
{
fwrite($logfile,"x");
exec("osascript -e 'tell app \"iTunes\" to set sound volume to $data'");
}
fclose($logfile);
}

?>
<p>  <img src="Actions1.png" width="131" height="66" border="0" usemap="#Map">
  <map name="Map">
    <area shape="rect" coords="101,46,123,59" href="index.php?q=louder">
    <area shape="rect" coords="44,6,85,46" href="index.php?q=playpause">
    <area shape="rect" coords="11,9,43,45" href="index.php?q=prev">
    <area shape="rect" coords="87,8,117,44" href="index.php?q=next">
    <area shape="rect" coords="3,47,25,60" href="index.php?q=quieter">
  </map>
</p>
</body>
</html>
--notice what I commented out - read what the lines say, if you're webs server isn't where I have it (via /Library/WebServer/Documents) you need to change a few things then 2 lines that say that thing, change it to the location of your server, these lines:
$data = file_get_contents("/Library/WebServer/Documents/volume.txt");

$logfile = fopen("/Library/WebServer/Documents/volume.txt",'w');

Now in your terminal, type this (you may need to change /Library... to the location of your web server:
cd /Library/WebServer/Documents
pico volume.txt
Control+O
Enter
Control+X

Now type in: sudo chmod 777 volume.txt

Step 3 Test to see if it works:
3) Type into Safari, or whatever browser you want to use: ip_address/index.php
YAY IT SHOULD WORK =D, here's a copy of the files I used down at the bottom or top, its in a zip file.

The volume icons control the volume - the next and previous control the track - the play button controls play and pause.


OH MY GOSH - I FORGOT TO GIVE CREDIT WHERE CREDIT IS DUE: I found out how to do this here: http://www.whatsmyip.org/itunesremote/
Attached Images
File Type: png Picture 3.png (29.5 KB, 41 views)
Attached Files
File Type: zip Archive.zip (22.1 KB, 14 views)
__________________

TechRestore - Best used Mac Laptop site ever


Ahhh only being 17 and knowing Mac's better than my family

Last edited by slooksterpsv; July 20th, 2005 at 02:12 PM.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 07:12 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.