Package com.tagtraum.tunes
Interface ITunes
-
public interface ITunes
Represents iTunes. Use this class to manipulate iTunes, songs (i.e.Track
s) in it etc. Typically, if you are usingAudioSong
s, there should never be a need to call this interface (or objects accessed through it) directly, asAudioSong
takes care of dispatching your calls transparently.- Author:
- Hendrik Schreiber
- See Also:
Track
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
void
eject()
Eject CD.Playlist
getCurrentPlaylist()
The playlist containing the currently targeted track.String
getCurrentStreamTitle()
The name of the current song in the playing stream (provided by streaming server).String
getCurrentStreamURL()
The URL of the playing stream or streaming web site (provided by streaming server).Track
getCurrentTrack()
The current targeted track.default Path
getDefaultITunesMusicLibraryFile()
Default file name of the iTunes Music Library.xml file.Path[]
getITunesMusicLibraryFiles()
Returns array of alliTunes Music Library.xml
oriTunes Library.xml
files we were able to find.LibraryPlaylist
getLibraryPlaylist()
Get main library playlist.Source
getLibrarySource()
Get main library source.Path
getMusicLibraryFile()
Actual music library file.boolean
getMute()
Mute.String
getName()
Name of the external library/player.PlayerState
getPlayerState()
Is iTunes stopped, paused, or playing?Image
getPrimaryArtworkFromCache(AudioSong song)
Returns the primary image for a song from a cache, should it exist.RepeatMode
getRepeatMode()
long
getTime()
The player's position within the currently playing track in milliseconds.default Track
getTrack(long id)
Returns the track with the given id from the library (playlist).default Track[]
getTracks(long... ids)
Get tracks from the library.String
getVersion()
Version of iTunes.float
getVolume()
Get sound volume.void
init()
Initialize this instance.boolean
isAvailable()
Indicates whether this instance is available for communication.boolean
isLibraryXMLSharingEnabled()
Indicates whether the sharing of theiTunes Library.xml
files is enabled in the iTunes advanced preferences.boolean
isPrimaryArtworkInCache(AudioSong song)
Indicates whether there is an image file in the cache.boolean
isSupportedPlayList(PlayList.Kind kind)
Indicates whether a distinguished kind ofPlayList
is supported.void
next()
Play next track.void
openLocation(String url)
Opens a given streaming URL.InputStream
openPrimaryArtworkStreamFromCache(AudioSong song)
Opens anInputStream
to image data from a cache (i.e.void
pause()
Pause.void
play(Playlist playlist)
Play playlist.void
play(Track track)
Play track.void
playPause()
Toggle play pause.void
previous()
Play previous track.void
removePrimaryArtworkFromCache(long songId)
Removes an artwork entry from the cache.void
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
void
setMusicLibraryFile(Path file)
Sets the actually used music library files.void
setMute(boolean mute)
Mutes.void
setRepeatMode(RepeatMode repeatMode)
void
setTime(long time)
Sets the player's position within the currently playing track in milliseconds.void
setVolume(float volume)
Set sound volume.void
stop()
Stop.
-
-
-
Method Detail
-
init
void init()
Initialize this instance.
-
getName
String getName()
Name of the external library/player.- Returns:
- name
-
isAvailable
boolean isAvailable()
Indicates whether this instance is available for communication. This is e.g. not the case, when an iTunes dialog is open.- Returns:
- true or false
-
isLibraryXMLSharingEnabled
boolean isLibraryXMLSharingEnabled()
Indicates whether the sharing of theiTunes Library.xml
files is enabled in the iTunes advanced preferences.- Returns:
- true or false
-
getDefaultITunesMusicLibraryFile
default Path getDefaultITunesMusicLibraryFile()
Default file name of the iTunes Music Library.xml file.- Returns:
- file or
null
, if we can't find one - See Also:
- Apple docs
-
getITunesMusicLibraryFiles
Path[] getITunesMusicLibraryFiles()
Returns array of alliTunes Music Library.xml
oriTunes Library.xml
files we were able to find. This list may be incomplete.- Returns:
iTunes Library.xml
files.
-
getMusicLibraryFile
Path getMusicLibraryFile()
Actual music library file.- Returns:
- music library file -
iTunes Music Library.xml
in the case of iTunes
-
setMusicLibraryFile
void setMusicLibraryFile(Path file)
Sets the actually used music library files. Note that this does not change the file that is used. This method should only be called by the app/framework itself, not by a plugin.- Parameters:
file
- library file, e.g.iTunes Music Library.xml
-
openPrimaryArtworkStreamFromCache
InputStream openPrimaryArtworkStreamFromCache(AudioSong song)
Opens anInputStream
to image data from a cache (i.e. not from the songs file).- Parameters:
song
- persistent song- Returns:
- inputstream to image data or null, if none exist
-
getPrimaryArtworkFromCache
Image getPrimaryArtworkFromCache(AudioSong song)
Returns the primary image for a song from a cache, should it exist.- Parameters:
song
- persistent song- Returns:
- Image object or null
- See Also:
openPrimaryArtworkStreamFromCache(AudioSong)
-
isPrimaryArtworkInCache
boolean isPrimaryArtworkInCache(AudioSong song)
Indicates whether there is an image file in the cache.- Parameters:
song
- song object- Returns:
- true or false
- See Also:
openPrimaryArtworkStreamFromCache(AudioSong)
-
removePrimaryArtworkFromCache
void removePrimaryArtworkFromCache(long songId)
Removes an artwork entry from the cache.- Parameters:
songId
- song id
-
playPause
void playPause()
Toggle play pause.
-
pause
void pause()
Pause.
-
stop
void stop()
Stop.
-
getMute
boolean getMute()
Mute.- Returns:
- mute
-
setMute
void setMute(boolean mute)
Mutes.- Parameters:
mute
- boolean value
-
eject
void eject()
Eject CD.
-
next
void next()
Play next track.
-
previous
void previous()
Play previous track.
-
setVolume
void setVolume(float volume)
Set sound volume.- Parameters:
volume
- volume
-
getVolume
float getVolume()
Get sound volume.- Returns:
- volume
-
play
void play(Track track)
Play track.- Parameters:
track
- track
-
play
void play(Playlist playlist)
Play playlist.- Parameters:
playlist
- playlist
-
getLibrarySource
Source getLibrarySource()
Get main library source.- Returns:
- library source
-
getLibraryPlaylist
LibraryPlaylist getLibraryPlaylist()
Get main library playlist.- Returns:
- library playlist
-
getVersion
String getVersion()
Version of iTunes.- Returns:
- version of iTunes
-
getTime
long getTime()
The player's position within the currently playing track in milliseconds. The underlying iTunes implementation may round to the nearest second.- Returns:
- position in ms
-
setTime
void setTime(long time)
Sets the player's position within the currently playing track in milliseconds. The underlying iTunes implementation may round to the nearest second.- Parameters:
time
- milliseconds
-
getPlayerState
PlayerState getPlayerState()
Is iTunes stopped, paused, or playing?- Returns:
- PlayerState
-
getCurrentPlaylist
Playlist getCurrentPlaylist()
The playlist containing the currently targeted track.- Returns:
- current playlist
-
getCurrentStreamTitle
String getCurrentStreamTitle()
The name of the current song in the playing stream (provided by streaming server).- Returns:
- current stream title
-
getCurrentStreamURL
String getCurrentStreamURL()
The URL of the playing stream or streaming web site (provided by streaming server).- Returns:
- current stream url
-
openLocation
void openLocation(String url)
Opens a given streaming URL.- Parameters:
url
- url
-
getCurrentTrack
Track getCurrentTrack()
The current targeted track.- Returns:
- current track or null, if there is no current track
-
getTrack
default Track getTrack(long id)
Returns the track with the given id from the library (playlist). This method may return a track object, even if the underlying track does not exist in the external player (iTunes/Music). If you need to be certain the track exists, callPlaylist.getTrack(long)
instead.- Parameters:
id
- id- Returns:
- track object or null. null means, the track does not exist, but a track object does not guarantee existence.
-
getTracks
default Track[] getTracks(long... ids)
Get tracks from the library. This method may return a track object, even if the underlying track does not exist in the external player (iTunes/Music). If you need to be certain the track exists, callPlaylist.getTracks(long...)
instead.- Returns:
- array of tracks existence of tracks is not guaranteed
-
isSupportedPlayList
boolean isSupportedPlayList(PlayList.Kind kind)
Indicates whether a distinguished kind ofPlayList
is supported.- Parameters:
kind
- kind- Returns:
- true or false
-
getRepeatMode
RepeatMode getRepeatMode()
-
setRepeatMode
void setRepeatMode(RepeatMode repeatMode)
-
addPropertyChangeListener
void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
addPropertyChangeListener
void addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
-
removePropertyChangeListener
void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
removePropertyChangeListener
void removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
-
-