The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mac::iTunes::AppleScript - control iTunes from Perl

SYNOPSIS

        use Mac::iTunes;

        my $itunes = Mac::iTunes->controller;

        $itunes->activate;
        $itunes->play;
        $itunes->quit;

DESCRIPTION

**This module is unmaintained**

Methods

new()

Returns a singleton object that can control iTunes.

play

Start playing the current selection

pause

Pause playback.

playpause

Toggle the play-pause button. If it's on play, it will pause, and if it's on pause, it will play.

next, next_track

Skip to the next track

previous, previous_track

Skip to the previous track

redo, back_track

Go back to the start of the current track

stop

Stop playback.

fast_forward

Fast forward through the current selection.

rewind

Rewind through the current selection.

resume

Start playing after fast forward or rewind

quit

Quit iTunes

open_url( URL )

Open an item from the given URL

Methods for tracks

current_track_name
add_track( FILE, PLAYLIST_NAME )

Add the unix style path FILE to the user playlist with name PLAYLIST_NAME. Relative paths are resolved according to the current working directory.

        add_track( 'mp3/song.mp3', 'Favorites' )

This function will create the playlist if it does not exist.

This function does not check if the track already exists in the playlist. If it does, you end up with duplicates.

track_file_exists

BROKEN!

Returns true if the file is already in the iTunes library.

The library actually stores aliases to the real files, so I can't simply check the file names---very frustrating.

get_track_at_position( POSITION [, PLAYLIST ] )
play_track( POSITION, [, PLAYLIST ] )
get_track_names_in_playlist( [ PLAYLIST ] )

Return an anonymous array of the names of the tracks in playlist PLAYLIST.

Uses the currently set playlist if you don't specify one.

Methods for playlists

get_playlists

Return an anonymous array of the names of the playlists.

set_playlist( NAME )

Set the current controller playlist.

Returns true if it succeeds, and false otherwise (for instance, if the playlist does not exist.

add_playlist( NAME )

Add a playlist with the name NAME. Any double-quotes in NAME become single quotes.

delete_playlist( NAME )

Delete all playlists with the name NAME.

playlist_exists( NAME )

Returns the number of playlists with name NAME.

Methods for windows

browser_window_visible( [TRUE|FALSE] )
eq_window_visible( [TRUE|FALSE] )

Returns the value of the visible property of the window. A window is visible if it is not minimized.

General AppleScript methods

tell( COMMAND )

The tell() method runs a simple applescript.

If the ITUNES_TELL environment variable is set to a true value, it prints the script to SDTERR before it runs it.

state

Returns the state of the iTunes application, represented by one of the following symbolic constants:

        STOPPED
        PLAYING
        PAUSED
        FAST_FORWARDING
        REWINDING

SOURCE AVAILABILITY

This source is in GitHub:

        https://github.com/CPAN-Adopt-Me/MacOSX-iTunes.git

AUTHOR

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2002-2007 brian d foy. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.