ipod_touch_webapp2.jpgThe next webapplication we discuss allows you to control itunes and winamp running on windows. without jailbraiking!
In the previous post we explain how you can set up a connection and how you simply launch an app.
But whats the use of that? So in this chapter we learn how to control iTunes and Winamp.

To keep the cost as low as possible we use free plugins. So everybody can follow along, although off course we like to hear other or even better solutions.

Before we start we look at Shopping list:
- Adobe director
- Director shell xtra (free)
- Itunes control trough command line (free)
- Winamp control trough command line (free)

in this quick example we use some different (easy) solutions like the “control trough the command line”. This is actually an extra step that isn’t paticular nesseccary, for example you can write directly an windows message (see next chapter) with the buddy Xtra. The buddy Xtra is a little bit more advanced and not free. So we keep on going the easy way..

There are some different approuches to interact with an program. We dont discuss all the options but two off those are basically sending keys or sendingwindows messages. Because we are now focus on Windows (see remote buddy for the mac) we want to use (the more stable) function sendmessage().

As mentiond before The sendmessage() is working in the buddy api.

LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);

Parameters

hWnd
[in]

Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.

Microsoft Windows Vista and later. Message sending is subject to User Interface Privilege Isolation (UIPI). The thread of a process can send messages only to message queues of threads in processes of lesser or equal integrity level.
Msg
[in] Specifies the message to be sent.
wParam
[in] Specifies additional message-specific information.
lParam
[in] Specifies additional message-specific information.

Off course this function can be directly used in your C++ apps. Although the codes are a little bit confusing. For example see the codes:

- Previous track button 40044
- Next track button 40048
- Play button 40045
– Pause/Unpause button 40046
- Stop button 40047

unfortunally there are some easy to use plugins / programs that we can use to make this much easyer! With the free programs we can acces this codes by simply writing then in a command line

So the itunes functions are like:

- start itunes and play: itch -p
- start winamp and play WAcommand.exe /play

this makes it mutch easyer to write an action in director.
before we look into the code we install the “extra’s”

Shell xtra
We use an free Shell xtra u can download at: http://staff.dasdeck.de/valentin/xtras/shell/win/
or directly http://staff.dasdeck.de/valentin/xtras/shell/win/v12.zip

iTunes control trough command line (free download)

http://code.google.com/p/itunes-control/

install the program once.

Winamp control trough command line (free download)
http://www.flippet.org/wacommand.html
set the program next to you director movie.

Get started coding!

again see the “how-to-control-a-pc-or-mac-with-the-iphone-ipod-touch” post for more information!

*note: the html / php and css are the same like the previous post. we one changed the director movie and plugin..

Director:

Dont forget to put the xtra file .x32 into your program files -> macromedia -> director -> configure -> Xtra folder and to set the file to ‘include’ in your projector (modify -> movie -> Xtra’s ) .

add the xtra line: _global.pShell = new (xtra “shell”)

on enterframe me
clearCache

_global.pXMLObj = new (xtra "XMLParser")
_global.pShell = new (xtra "shell")
_global.pXMLObj.parseURL ("C:\wamp\www\XmlFile2.xml")
end

the moviescript contains the next code. 

on enterframe me

-- itunes vars
if member("text").text = "itunes" then
shell_cmd("itch -p", RETURN)
WriteOutXMLFiles
member("text").text =  "itunes started"
end if

end

simple change the member text vars and set the shell_cmd
some simple command lines for the itunes:

playback controls:

    -p, --play-pause                 If currently paused, begin playing.  If
                                     currently playing, pause playback.
        --pause                      Pause playback.
        --play                       Play the current track.
    -s, --stop                       Stop playback.
    -n, --next-track                 Go to the next track.
    -N, --previous-track             Go to the previous track.
    -m, --mute                       Mute the audio.
    -M, --unmute                     Unmute the audio.
    -v, --volume number              Set the volume to X percentage points.
        --volume-down [number]       Decrease the volume by X percentage points
                                     (default 10).
        --volume-up [number]         Increase the volume by X percentage points
                                     (default 10).

look for more itunes codes here:
http://code.google.com/p/itunes-control/

look for more winamp codes here:
http://www.flippet.org/wacommand-commands.html

Our example contains the basic function to controlling iTunes and Winamp:
- start
- play / pause
- stop
- next
- previous
- volume Up
- volume Down
- quit

Download the project files here:
files_ipod_tunes_winamp.zip

Again, this is just an quick axample,you can build and expand the functions and possibility’s. For example make a nicer looking interface, build an search function or add covers to you webapplication.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Furl
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati