com.dt.iTunesController
Class iTunes

java.lang.Object
  extended by com.dt.iTunesController.iTunes

public class iTunes
extends java.lang.Object

Defines the top-level iTunes application object. This interface defines the top-level iTunes application object. All other iTunes interfaces are accessed through this object.


Constructor Summary
iTunes()
          Initiate iTunes Controller.
 
Method Summary
 void addEventHandler(iTunesEventsInterface itef)
          Add an event handler to the iTunes controller.
 void backTrack()
          Reposition to the beginning of the current track or go to the previous track if already at start of current track.
 ITEQPreset createEQPreset(java.lang.String eqPresetName)
          Creates a new EQ preset.
 ITUserPlaylist createFolder(java.lang.String folderName)
          Creates a new folder in the main library.
 ITUserPlaylist createFolderInSource(java.lang.String folderName, ITSource iSource)
          Creates a new folder in an existing source.
 ITPlaylist createPlaylist(java.lang.String playlistName)
          Creates a new playlist in the main library.
 ITPlaylist createPlaylistInSource(java.lang.String playlistName, ITSource source)
          Creates a new playlist in an existing source.
 void fastForward()
          Skip forward in a playing track.
 ITBrowserWindow getBrowserWindow()
           
 boolean getCheckVersion(int majorVersion, int minorVersion)
          Returns true if this version of the iTunes type library is compatible with the specified version.
 ITPlaylist getCurrentPlaylist()
          Returns the playlist containing the currently targeted track.
 ITTrack getCurrentTrack()
          Returns the currently targetd track.
 ITObject getITObjectByID(int sourceID, int playlistID, int trackID, int databaseID)
          Returns an IITObject corresponding to the specified IDs.
 long getITObjectPersistentIDHigh(ITObject iObject)
          Returns the high 32 bits of the persistent ID of the specified IITObject.
 long getITObjectPersistentIDLow(ITObject iObject)
          Returns the low 32 bits of the persistent ID of the specified IITObject.
 ITLibraryPlaylist getLibraryPlaylist()
          Returns the main library playlist in the main library source.
 ITSource getLibrarySource()
          Returns the source that represents the main library.
 boolean getMute()
          Returns true if the sound output is muted.
 ITObjectPersistentID getObjectPersistentIDs(ITObject iObject)
           
 void getPlayerButtonsState(boolean previousEnabled, java.lang.String playPause, boolean nextEnabled)
          Retrieves the current state of the player buttons in the window containing the currently targeted track.
 int getPlayerPosition()
          Returns the player's position within the currently playing track in seconds.
 ITPlayerState getPlayerState()
          Returns the current player state.
 ITTrackCollection getSelectedTracks()
          Returns a collection containing the currently selected track or tracks.
 int getSoundVolume()
          Returns the sound output volume (0=minimum, 100=maximum).
 ITSourceCollection getSources()
          Returns a collection of music sources (music library, CD, device, etc.).
 java.lang.String getVersion()
          Returns the version of the iTunes application.
 void gotoMusicStoreHomePage()
          Go to the iTunes Store home page.
 void nextTrack()
          Advance to the next track in the current playlist.
 void openURL(java.lang.String url)
          Open the specified iTunes Store or streaming audio URL.
 void pause()
          Pause playback.
 void play()
          Play the currently targeted track.
 void playFile(java.lang.String filePath)
          Play the specified file path, adding it to the library if not already present.
 void playPause()
          Toggle the playing/paused state of the current track.
 void previousTrack()
          Return to the previous track in the current playlist.
 void quit()
          Exits the iTunes application.
 void resume()
          Disable fast forward/rewind and resume playback, if playing.
 void rewind()
          Skip backwards in a playing track.
 void setMute(boolean shouldMute)
          Sets sound output mute state.
 void setPlayerPosition(int playerPos)
          Sets the player's position within the currently playing track in seconds.
 void setSoundVolume(int volume)
          Sets the sound output volume (0=minimum, 100=maximum).
 void stop()
          Stop playback.
 void subscribeToPodcast(java.lang.String url)
          Subscribes to the specified podcast feed URL.
 void updateIPod()
          Update the contents of the iPod.
 void updatePodcastFeeds()
          Updates all podcast feeds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

iTunes

public iTunes()
Initiate iTunes Controller.

Method Detail

addEventHandler

public void addEventHandler(iTunesEventsInterface itef)
Add an event handler to the iTunes controller.

Parameters:
itef - The class that will handle the iTunes events.

backTrack

public void backTrack()
Reposition to the beginning of the current track or go to the previous track if already at start of current track.


fastForward

public void fastForward()
Skip forward in a playing track.


nextTrack

public void nextTrack()
Advance to the next track in the current playlist.


pause

public void pause()
Pause playback.


play

public void play()
Play the currently targeted track.


playFile

public void playFile(java.lang.String filePath)
Play the specified file path, adding it to the library if not already present.


playPause

public void playPause()
Toggle the playing/paused state of the current track.


previousTrack

public void previousTrack()
Return to the previous track in the current playlist.


resume

public void resume()
Disable fast forward/rewind and resume playback, if playing.


rewind

public void rewind()
Skip backwards in a playing track.


stop

public void stop()
Stop playback.


getPlayerButtonsState

public void getPlayerButtonsState(boolean previousEnabled,
                                  java.lang.String playPause,
                                  boolean nextEnabled)
Retrieves the current state of the player buttons in the window containing the currently targeted track. If there is no currently targeted track, returns the current state of the player buttons in the main browser window.


getCheckVersion

public boolean getCheckVersion(int majorVersion,
                               int minorVersion)
Returns true if this version of the iTunes type library is compatible with the specified version.

Parameters:
majorVersion - Major version of iTunes interface.
minorVersion - Minor version of iTunes interface.
Returns:
Returns true if this version is compatible with the indicated interface version.

getITObjectByID

public ITObject getITObjectByID(int sourceID,
                                int playlistID,
                                int trackID,
                                int databaseID)
Returns an IITObject corresponding to the specified IDs. The object may be a source, playlist, or track.

Parameters:
sourceID - The ID that identifies the source. Valid for a source, playlist, or track.
playlistID - The ID that identifies the playlist. Valid for a playlist or track. Must be zero for a source.
trackID - The ID that identifies the track within the playlist. Valid for a track. Must be zero for a source or playlist.
databaseID - The ID that identifies the track, independent of its playlist. Valid for a track. Must be zero for a source or playlist.
Returns:
Returns an IITObject object corresponding to the specified IDs. Will be set to NULL if no object could be retrieved.

createPlaylist

public ITPlaylist createPlaylist(java.lang.String playlistName)
Creates a new playlist in the main library.

Parameters:
playlistName - The name of the new playlist (may be empty).
Returns:
Returns an ITPlaylist object corresponding to the new playlist.

openURL

public void openURL(java.lang.String url)
Open the specified iTunes Store or streaming audio URL.

Parameters:
url - The URL to open. The length of the URL cannot exceed 512 characters. iTunes Store URLs start with itms:// or itmss://. Streaming audio URLs start with http://.

gotoMusicStoreHomePage

public void gotoMusicStoreHomePage()
Go to the iTunes Store home page.


updateIPod

public void updateIPod()
Update the contents of the iPod.


quit

public void quit()
Exits the iTunes application.


createEQPreset

public ITEQPreset createEQPreset(java.lang.String eqPresetName)
Creates a new EQ preset. The EQ preset will be created "flat", i.e. the preamp and all band levels will be set to 0. EQ preset names cannot start with leading spaces. If you specify a name that starts with leading spaces they will be stripped out. If eqPresetName is empty, the EQ preset will be created with a default name.

Parameters:
eqPresetName - The name of the new EQ Preset (may be empty)
Returns:
Returns an ITEQPreset object corresponding to the new EQ Preset.

createPlaylistInSource

public ITPlaylist createPlaylistInSource(java.lang.String playlistName,
                                         ITSource source)
Creates a new playlist in an existing source. You may not be able to create a playlist in every source. For example, you cannot create a playlist in an audio CD source, or in an iPod source if it is in auto update mode. If playlistName is empty, the playlist will be created with a default name.

Parameters:
playlistName - The name of the new playlist (may be empty).
source - The source that will contain the new playlist.
Returns:
Returns an ITPlaylist object corresponding to the new playlist.

subscribeToPodcast

public void subscribeToPodcast(java.lang.String url)
Subscribes to the specified podcast feed URL. Any "unsafe" characters in the URL should already be converted into their corresponding escape sequences, iTunes will not do this.

Parameters:
url - The URL to subscribe to.

updatePodcastFeeds

public void updatePodcastFeeds()
Updates all podcast feeds. This is equivalent to the user pressing the Update button when Podcasts is selected in the Source list.


createFolder

public ITUserPlaylist createFolder(java.lang.String folderName)
Creates a new folder in the main library. If folderName is empty, the folder will be created with a default name.

Parameters:
folderName - The name of the new folder (may be empty).
Returns:
Returns an ITPlaylist object corresponding to the new folder.

createFolderInSource

public ITUserPlaylist createFolderInSource(java.lang.String folderName,
                                           ITSource iSource)
Creates a new folder in an existing source. You may not be able to create a folder in every source. For example, you cannot create a folder in an audio CD source, or in an iPod source if it is in auto update mode. If folderName is empty, the folder will be created with a default name.

Parameters:
folderName - The name of the new folder (may be empty)
iSource - The source that will contain the new folder.
Returns:
Returns an ITPlaylist object corresponding to the new folder.

getSources

public ITSourceCollection getSources()
Returns a collection of music sources (music library, CD, device, etc.).

Returns:
Collection of ITSource objects.

setSoundVolume

public void setSoundVolume(int volume)
Sets the sound output volume (0=minimum, 100=maximum).

Parameters:
volume - New sound output volume

getSoundVolume

public int getSoundVolume()
Returns the sound output volume (0=minimum, 100=maximum).

Returns:
Current sound output volume

setMute

public void setMute(boolean shouldMute)
Sets sound output mute state.

Parameters:
shouldMute - If true, sound output will be muted.

getMute

public boolean getMute()
Returns true if the sound output is muted.

Returns:
True if sound output is muted.

getPlayerState

public ITPlayerState getPlayerState()
Returns the current player state.

Returns:
Returns the current player state.

setPlayerPosition

public void setPlayerPosition(int playerPos)
Sets the player's position within the currently playing track in seconds. If playerPos specifies a position before the beginning of the track, the position will be set to the beginning. If playerPos specifies a position after the end of the track, the position will be set to the end.

Parameters:
playerPos - The player's position within the currently playing track in seconds.

getPlayerPosition

public int getPlayerPosition()
Returns the player's position within the currently playing track in seconds.

Returns:
The player's position within the currently playing track in seconds.

getLibrarySource

public ITSource getLibrarySource()
Returns the source that represents the main library. You can also find the main library source by iterating over iTunes.getSources() and looking for an ITSource of kind ITSourceKindLibrary.

Returns:
Returns the source that represents the main library.

getLibraryPlaylist

public ITLibraryPlaylist getLibraryPlaylist()
Returns the main library playlist in the main library source.

Returns:
An IITLibraryPlaylist object corresponding to the main library playlist.

getCurrentTrack

public ITTrack getCurrentTrack()
Returns the currently targetd track.

Returns:
An ITTrack object corresponding to the currently targeted track. Will be set to NULL if there is no currently targeted track.

getCurrentPlaylist

public ITPlaylist getCurrentPlaylist()
Returns the playlist containing the currently targeted track.

Returns:
An ITPlaylist object corresponding to the playlist containing the currently targeted track. Will be set to NULL if there is no currently targeted playlist.

getSelectedTracks

public ITTrackCollection getSelectedTracks()
Returns a collection containing the currently selected track or tracks. The frontmost visible window in iTunes must be a browser or playlist window. If there is no frontmost visible window (e.g. iTunes is minimized to the system tray), the main browser window is used.

Returns:
Collection of ITrack objects. Will be set to NULL if there is no current selection.

getVersion

public java.lang.String getVersion()
Returns the version of the iTunes application.

Returns:

getITObjectPersistentIDHigh

public long getITObjectPersistentIDHigh(ITObject iObject)
Returns the high 32 bits of the persistent ID of the specified IITObject. See the documentation on IITObject for more information on persistent IDs. The object may be a source, playlist, or track.

Parameters:
iObject - The object to fetch the High Persistent ID.
Returns:
The high 32 bits of the 64-bit persistent ID.

getITObjectPersistentIDLow

public long getITObjectPersistentIDLow(ITObject iObject)
Returns the low 32 bits of the persistent ID of the specified IITObject. See the documentation on IITObject for more information on persistent IDs. The object may be a source, playlist, or track.

Parameters:
iObject - The object to fetch the Low Persistent ID.
Returns:
The low 32 bits of the 64-bit persistent ID.

getObjectPersistentIDs

public ITObjectPersistentID getObjectPersistentIDs(ITObject iObject)

getBrowserWindow

public ITBrowserWindow getBrowserWindow()