Package com.tagtraum.tunes
Interface ITunes
-
public interface ITunesRepresents iTunes. Use this class to manipulate iTunes, songs (i.e.Tracks) in it etc. Typically, if you are usingAudioSongs, there should never be a need to call this interface (or objects accessed through it) directly, asAudioSongtakes 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 voidaddPropertyChangeListener(PropertyChangeListener propertyChangeListener)voidaddPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)voideject()Eject CD.PlaylistgetCurrentPlaylist()The playlist containing the currently targeted track.StringgetCurrentStreamTitle()The name of the current song in the playing stream (provided by streaming server).StringgetCurrentStreamURL()The URL of the playing stream or streaming web site (provided by streaming server).TrackgetCurrentTrack()The current targeted track.default PathgetDefaultITunesMusicLibraryFile()Default file name of the iTunes Music Library.xml file.Path[]getITunesMusicLibraryFiles()Returns array of alliTunes Music Library.xmloriTunes Library.xmlfiles we were able to find.LibraryPlaylistgetLibraryPlaylist()Get main library playlist.SourcegetLibrarySource()Get main library source.PathgetMusicLibraryFile()Actual music library file.booleangetMute()Mute.StringgetName()Name of the external library/player.PlayerStategetPlayerState()Is iTunes stopped, paused, or playing?ImagegetPrimaryArtworkFromCache(AudioSong song)Returns the primary image for a song from a cache, should it exist.RepeatModegetRepeatMode()longgetTime()The player's position within the currently playing track in milliseconds.default TrackgetTrack(long id)Returns the track with the given id from the library (playlist).default Track[]getTracks(long... ids)Get tracks from the library.StringgetVersion()Version of iTunes.floatgetVolume()Get sound volume.voidinit()Initialize this instance.booleanisAvailable()Indicates whether this instance is available for communication.booleanisLibraryXMLSharingEnabled()Indicates whether the sharing of theiTunes Library.xmlfiles is enabled in the iTunes advanced preferences.booleanisPrimaryArtworkInCache(AudioSong song)Indicates whether there is an image file in the cache.booleanisSupportedPlayList(PlayList.Kind kind)Indicates whether a distinguished kind ofPlayListis supported.voidnext()Play next track.voidopenLocation(String url)Opens a given streaming URL.InputStreamopenPrimaryArtworkStreamFromCache(AudioSong song)Opens anInputStreamto image data from a cache (i.e.voidpause()Pause.voidplay(Playlist playlist)Play playlist.voidplay(Track track)Play track.voidplayPause()Toggle play pause.voidprevious()Play previous track.voidremovePrimaryArtworkFromCache(long songId)Removes an artwork entry from the cache.voidremovePropertyChangeListener(PropertyChangeListener propertyChangeListener)voidremovePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)voidsetMusicLibraryFile(Path file)Sets the actually used music library files.voidsetMute(boolean mute)Mutes.voidsetRepeatMode(RepeatMode repeatMode)voidsetTime(long time)Sets the player's position within the currently playing track in milliseconds.voidsetVolume(float volume)Set sound volume.voidstop()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.xmlfiles 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.xmloriTunes Library.xmlfiles we were able to find. This list may be incomplete.- Returns:
iTunes Library.xmlfiles.
-
getMusicLibraryFile
Path getMusicLibraryFile()
Actual music library file.- Returns:
- music library file -
iTunes Music Library.xmlin 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 anInputStreamto 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 ofPlayListis 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)
-
-