Interface MediaLibrary
-
- All Known Implementing Classes:
AbstractMediaLibrary
,HibernateMediaLibrary
public interface MediaLibrary
Media library.
In prior versions, this interface returned
Song
s instead ofAudioSong
s. Since beaTunes 3, this has been changed. This allows you to simply call setters and not worry about callingstore(com.tagtraum.audiokern.AudioSong, String)
- changes are persisted automatically in the internal database, iTunes (or whatever other audioplayer,ITunes
) as well as the file.- Author:
- Hendrik Schreiber
- See Also:
PlayList
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
addMediaLibraryListener(MediaLibraryListener listener)
void
addPlayListDataListener(ListDataListener l)
void
addPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Lets you register a listener that receives events when a playlist property is changed.void
addPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Lets you register a listener that receives events when a playlist property is changed.void
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
void
cancelSynchronization()
Cancels any ongoing synchronization.int
countSongs()
Number of songs in the library.int
countSongsWithPropertyValue(String propertyName, Object propertyValue)
Count all songs with a propertyequal
to the given value.int
countUnprotectedSongsAddedAfter(Date time)
Counts unprotected songs added after a certain date.PlayList
createFolder()
Creates a new folder under the Music playlist/folder.PlayList
createFolder(Long parentId)
Creates a new folder at a specific location.PlayList
createPlayList(Long id, Long parentId, String name, boolean folder)
Creates a newPlayList
object with the given name and id.PlayList
createPlayList(Long parentId, String name)
Creates a new PlayList at a specific location.PlayList
createPlayList(String name)
Creates a new PlayList under the Music playlist/folder.void
deleteAllFingerprints()
Delete all fingerprints from the database to save disk space.void
deletePlayList(long id)
Deletes a playlist from the library.AudioSong
fetchCollections(AudioSong song)
Loads dependent collections that otherwise wouldn't have been loaded.void
flushPendingWrites()
Flush any pending writes (blocks until all writes happened).Set<Set<Long>>
getAcousticallyIdenticalSongIds()
Deprecated.Set<Set<Long>>
getAcousticallyIdenticalSongIds(int maxSubprintMatchAttempts)
Deprecated.Set<Set<Long>>
getAcousticallyIdenticalSongIds(Set<Long> ids)
Returns a collection of sets that each contain song ids of acoustically "identical" songs.Set<Set<Long>>
getAcousticallyIdenticalSongIds(Set<Long> ids, int maxSubprintMatchAttempts)
Returns a collection of sets that each contain song ids of acoustically "identical" songs.Album
getAlbum(Album.Key key)
Deprecated.Set<Album.Key>
getAlbumKeys()
Returns the set of all valid album keys.List<Long>
getAlbumSongIds(String album, String artist)
Returns a list of song ids for songs specified by the given album and artist.List<AudioSong>
getAlbumSongs(String album, String artist)
Returns a list of songs specified by the given album and artist.Version
getApplicationVersion()
Returns the iTunes application version as specified in the iTunes Music Library.xml.ExecutorService
getAudioMetaDataExecutor()
Returns en executor service that should be used for any write access toAudioMetaData
related tasks.File
getDatabaseDir()
List<String>
getDuplicateTitles()
Returns a list of titles that have exact duplicates.List<String>
getDuplicateTrackIds()
Returns a list of track ids that correspond to more than one song.GenreIRILookupService
getGenreIRILookupService()
Returns current genre IRI lookup service.List<String>
getGenres()
<T> T
getImplementation(Class<T> klass)
long
getLastSynchronizationTimestamp()
Timestamp of last synchronization of the current library.PlayList
getLibrary()
Returns the master playlist that contains all library objects.LibraryDescriptor
getLibraryDescriptor()
Returns the library descriptor.ReentrantLock
getLock(Long songId)
Provides a lock object for a song id.Long
getPersistentId()
Returns the iTunes library persistent id as specified in theiTunes Music Library.xml
.PlayList
getPlayList(long playListPersistentId)
Get aPlayList
for an id.PropertyChangeListener[]
getPlayListPropertyChangeListeners()
PropertyChangeListener[]
getPlayListPropertyChangeListeners(String property)
List<PlayList>
getPlayLists()
List of all playlists.TagCollection
getPopularTagCollection(int numberOfTags)
Returns theTagCollection
for the X most common tags.long
getPreviousToLastSynchronizationTimestamp()
Timestamp of the previous to last synchronization of the current library.PropertyChangeListener[]
getPropertyChangeListeners()
PropertyChangeListener[]
getPropertyChangeListeners(String property)
Collection<Set<Long>>
getSimilarTitles()
Returns a collection of id sets that point to songs with similar or identical titles.AudioSong
getSong(Long id)
Gets a Song, given its id (Song.getId()
.List<Long>
getSongIds()
Returns anIterable
that can be used to iterate over all song ids.Set<Long>
getSongIds(PlayList.Kind... kinds)
Returns all ids that are in the given set ofPlayList.Kind
s.List<Long>
getSongIdsWithoutProperties(Map<String,Object> properties)
Get all song ids for songs that match none of the given properties.List<Long>
getSongIdsWithProperties(Map<String,Object> properties)
Get all song ids for songs that match all given properties.List<Long>
getSongIdsWithPropertiesILike(Map<String,Object> properties)
Get all song ids of songs with a properties that are ilike the given properties (case-insensitive).List<Long>
getSongIdsWithPropertiesLike(Map<String,Object> properties)
Get all song ids of songs with a properties that are like the given properties.<T> List<T>
getSongPropertyValues(String propertyName)
All possible values for a given property.<T> List<T>
getSongPropertyValues(String propertyName, String restrictionPropertyName, Object restrictionPropertyValue)
Gets all property values of propertypropertyName
for songs withrestrictionPropertyName
equalingrestrictionPropertyValue
.<T> List<T>
getSongPropertyValues(String propertyName, List<T> valueList)
All possible values for a given property.Iterable<AudioSong>
getSongs()
Returns anIterable
that can be used to iterate over all songs.Iterable<AudioSong>
getSongs(Collection<Long> ids)
Returns anIterable
that can be used to iterate over the specified songs.default Iterable<AudioSong>
getSongsOrderedBy(String sortProperty)
Returns anIterable
that can be used to iterate over all songs.Iterable<AudioSong>
getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)
Returns anIterable
that can be used to iterate over all songs.Iterable<AudioSong>
getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Returns anIterable
that can be used to iterate over all songs.List<AudioSong>
getSongsWithFileAndSize(String filename, int size)
Deprecated.List<AudioSong>
getSongsWithNameArtistAlbumTotalTime(String name, String artist, String album, int time)
Deprecated.List<AudioSong>
getSongsWithoutProperties(Map<String,Object> properties)
Get all songs without propertiesequal
to the given value.List<AudioSong>
getSongsWithProperties(Map<String,Object> properties)
Get all song ids for songs that match all given properties.List<AudioSong>
getSongsWithPropertiesLike(Map<String,Object> properties)
Get all songs with a properties that are like the given properties.Set<AudioSong>
getSongsWithTrackIdTotalTime(Set<AudioId> ids, int time)
Deprecated.TagCollection
getTagCollection()
Returns theTagCollection
for the entire library.ITunes
getTunes()
Returns the currently associated audio player, probably iTunes.ExecutorService
getTunesExecutor()
Returns en executor service that should be used for any write access toITunes
related tasks.List<AudioSong>
getUnprotectedSongsAddedAfter(Date time)
Return unprotected songs added after a certain date.void
init()
Initializes this component and its sub-components.boolean
isEmbedAudioMetaData()
Shall all data be embedded into the audio files, when writing?boolean
isForceAudioMetaDataWrites()
Shall new values always be written, even, if the old value seems to be identical? This can happen, when the internal database is out of sync with actual values in audio files or iTunes.boolean
isForceRecovery()
Is the recovery flag set?boolean
isNewDatabase()
boolean
isOneWeekOld()
boolean
isSupportedPlayList(PlayList.Kind kind)
Indicates whether a distinguished kind ofPlayList
is supported.boolean
isSynchronizing()
Indicates, whether we are currently synchronizing.Lock
lock(Long songId)
Provides a locked lock for a song id.boolean
needsRefresh()
void
refresh()
Reloads all objects that are connected to the music library.void
refresh(boolean blockingCall, boolean manuallyInitiated, boolean full)
Reloads all objects that are connected to the music library.boolean
removeMediaLibraryListener(MediaLibraryListener listener)
void
removePlayListDataListener(ListDataListener l)
void
removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
removePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
void
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
removePropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
void
serialExecute(Runnable runnable)
Execute the runnable withgetTunesExecutor()
, but not beforegetAudioMetaDataExecutor()
has run through.<V> V
serialExecute(Callable<V> callable)
Execute the callable withgetTunesExecutor()
, but not beforegetAudioMetaDataExecutor()
has run through.void
setDatabaseDir(File databaseDir)
void
setEmbedAudioMetaData(boolean embedAudioMetaData)
Shall all data be embedded into audio files or just those fields that are supported by iTunes.void
setForceAudioMetaDataWrites(boolean force)
Shall new values always be written, even, if the old value seems to be identical? This can happen, when the internal database is out of sync with actual values in audio files or iTunes.void
setGenreIRILookupService(GenreIRILookupService service)
Lets you set theGenreIRILookupService
.void
setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
Sets the library descriptor.void
setNewDatabase(boolean newDatabase)
void
setRecoveryFlag()
void
setUIDelegate(MediaLibraryUIDelegate uiDelegate)
void
shutdown()
Shuts down this component and its sub-components.<V> V
smuggle(Callable<V> callable)
Smuggles read-only calls to thegetTunesExecutor()
even when it's blocked.void
store(AudioSong song)
Stores a song in the beaTunes database.void
store(AudioSong song, String changedProperty)
Stores a song in the beaTunes database and clears any sortorder caches in the playlist objects this song might be in, if the playlist is sorted by the changed property.void
store(PlayList playList)
Stores a playlist in the beaTunes database.void
store(MatchListInfo matchListInfo)
Store the given info.void
store(Iterable<AudioSong> songs)
Stores a collection of songs in the beaTunes database.
-
-
-
Method Detail
-
getImplementation
<T> T getImplementation(Class<T> klass)
-
setRecoveryFlag
void setRecoveryFlag()
-
isForceRecovery
boolean isForceRecovery()
Is the recovery flag set?- Returns:
- true or false
-
init
void init()
Initializes this component and its sub-components.
-
shutdown
void shutdown() throws ShutdownVetoException
Shuts down this component and its sub-components.- Throws:
ShutdownVetoException
- if this component wants to veto the shutdown. This exception is not guaranteed to be honored, i.e. a calling component may simply ignore it
-
getGenreIRILookupService
GenreIRILookupService getGenreIRILookupService()
Returns current genre IRI lookup service.- Returns:
- service
-
setGenreIRILookupService
void setGenreIRILookupService(GenreIRILookupService service)
Lets you set theGenreIRILookupService
.- Parameters:
service
- service
-
getTunesExecutor
ExecutorService getTunesExecutor()
Returns en executor service that should be used for any write access toITunes
related tasks. This takes care of synchronizing your access as well as using the correct thread.Typically when working with
AudioSong
objects, synchronization happens behind the scenes, so you don't have to use this service. However, there may be situations in which you want to access aTrack
directly. If you intend to write, you should use this executor.The service is managed by the application, i.e. you cannot terminate or shut it down.
- Returns:
- executor service
- See Also:
TunesUtilities.getExecutorService()
-
getAudioMetaDataExecutor
ExecutorService getAudioMetaDataExecutor()
Returns en executor service that should be used for any write access toAudioMetaData
related tasks. This takes care of synchronizing your access as well as using the correct thread.Typically when working with
AudioSong
objects, synchronization happens behind the scenes, so you don't have to use this service. However, there may be situations in which you want to access aAudioMetaData
directly. If you intend to write, you should use this executor.The service is managed by the application, i.e. you cannot terminate or shut it down.
- Returns:
- executor service
- See Also:
AudioMetaData.getExecutorService()
-
serialExecute
<V> V serialExecute(Callable<V> callable) throws Exception
Execute the callable withgetTunesExecutor()
, but not beforegetAudioMetaDataExecutor()
has run through.- Type Parameters:
V
- return type- Parameters:
callable
- callable- Returns:
- return value, may be null
- Throws:
Exception
-
serialExecute
void serialExecute(Runnable runnable)
Execute the runnable withgetTunesExecutor()
, but not beforegetAudioMetaDataExecutor()
has run through.- Parameters:
runnable
- runnable
-
smuggle
<V> V smuggle(Callable<V> callable) throws Exception
Smuggles read-only calls to thegetTunesExecutor()
even when it's blocked.- Type Parameters:
V
- return type- Parameters:
callable
- callable- Returns:
- return value, may be null
- Throws:
Exception
-
getLock
ReentrantLock getLock(Long songId)
Provides a lock object for a song id.- Parameters:
songId
- song id- Returns:
- exclusive, reentrant lock
-
lock
Lock lock(Long songId)
Provides a locked lock for a song id.- Parameters:
songId
- song id- Returns:
- exclusive, reentrant lock
-
getTunes
ITunes getTunes()
Returns the currently associated audio player, probably iTunes.- Returns:
- audio player
-
isNewDatabase
boolean isNewDatabase()
-
setNewDatabase
void setNewDatabase(boolean newDatabase)
-
countSongs
int countSongs()
Number of songs in the library.- Returns:
- number of songs in the library.
-
countSongsWithPropertyValue
int countSongsWithPropertyValue(String propertyName, Object propertyValue)
Count all songs with a propertyequal
to the given value.- Parameters:
propertyName
- name of a propertypropertyValue
- value of a property- Returns:
- list of songs whose property has the required value
-
getSongsWithProperties
List<AudioSong> getSongsWithProperties(Map<String,Object> properties)
Get all song ids for songs that match all given properties.- Parameters:
properties
- name-value pairs- Returns:
- list of songs whose properties have the required values
-
getSongsWithoutProperties
List<AudioSong> getSongsWithoutProperties(Map<String,Object> properties)
Get all songs without propertiesequal
to the given value.- Parameters:
properties
- name-value pairs- Returns:
- list of song whose properties do not the given values
-
getSongIdsWithProperties
List<Long> getSongIdsWithProperties(Map<String,Object> properties)
Get all song ids for songs that match all given properties. All key value pairs are implicitly connected using theAND
operator.- Parameters:
properties
- name-value pairs- Returns:
- list of song ids whose properties have the required value
-
getSongIdsWithoutProperties
List<Long> getSongIdsWithoutProperties(Map<String,Object> properties)
Get all song ids for songs that match none of the given properties. All key value pairs are implicitly connected using theAND
operator.- Parameters:
properties
- name-value pairs- Returns:
- list of song ids whose properties have the required value
-
getSongsWithPropertiesLike
List<AudioSong> getSongsWithPropertiesLike(Map<String,Object> properties)
Get all songs with a properties that are like the given properties.- Parameters:
properties
- name-value pairs- Returns:
- list of songs whose string property contains the given value
-
getSongIdsWithPropertiesLike
List<Long> getSongIdsWithPropertiesLike(Map<String,Object> properties)
Get all song ids of songs with a properties that are like the given properties.- Parameters:
properties
- name-value pairs- Returns:
- list of song ids whose string property contains the given value
-
getSongIdsWithPropertiesILike
List<Long> getSongIdsWithPropertiesILike(Map<String,Object> properties)
Get all song ids of songs with a properties that are ilike the given properties (case-insensitive).- Parameters:
properties
- name-value pairs- Returns:
- list of song ids whose string property contains the given value
-
getSongs
Iterable<AudioSong> getSongs()
Returns anIterable
that can be used to iterate over all songs. Shortcut forPlayList.getSongs()
called on the library playlist (getLibrary()
). Note, that theIterable
may be aList
, which would expose other, non-sequential means of accessing the content.- Returns:
- an object from which one can get an iterator
-
getSongsOrderedBy
default Iterable<AudioSong> getSongsOrderedBy(String sortProperty)
Returns anIterable
that can be used to iterate over all songs. Shortcut forPlayList.getSongsOrderedBy(String, PlayList.SortDirection)
called on the library playlist (getLibrary()
).- Parameters:
sortProperty
- property name to order by- Returns:
- an object from which one can get an iterator
-
getSongsOrderedBy
Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)
Returns anIterable
that can be used to iterate over all songs. Shortcut forPlayList.getSongsOrderedBy(String, PlayList.SortDirection)
called on the library playlist (getLibrary()
).- Parameters:
sortProperty
- property name to order bydirection
- direction- Returns:
- an object from which one can get an iterator
-
getSongsOrderedBy
Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Returns anIterable
that can be used to iterate over all songs. Shortcut forPlayList.getSongsOrderedBy(String, PlayList.SortDirection)
called on the library playlist (getLibrary()
).- Parameters:
sortProperty
- property name to order bydirection
- directionlimit
- max number of songs to return- Returns:
- an object from which one can get an iterator
-
getSongs
Iterable<AudioSong> getSongs(Collection<Long> ids)
Returns anIterable
that can be used to iterate over the specified songs.- Parameters:
ids
- collection of ids- Returns:
- an object from which one can get an iterator
-
getSongIds
List<Long> getSongIds()
Returns anIterable
that can be used to iterate over all song ids.- Returns:
- an object from which one can get an iterator
-
getSongIds
Set<Long> getSongIds(PlayList.Kind... kinds)
Returns all ids that are in the given set ofPlayList.Kind
s.- Parameters:
kinds
- kind- Returns:
- set of ids
-
getSong
AudioSong getSong(Long id)
Gets a Song, given its id (Song.getId()
.- Parameters:
id
- id- Returns:
- song or
null
, if not found
-
fetchCollections
AudioSong fetchCollections(AudioSong song)
Loads dependent collections that otherwise wouldn't have been loaded. Default impl. does nothing.- Parameters:
song
- song to 'complete'- Returns:
- song complete with associated collections
-
getSongPropertyValues
<T> List<T> getSongPropertyValues(String propertyName)
All possible values for a given property.- Parameters:
propertyName
- property- Returns:
- values for a given property
-
getSongPropertyValues
<T> List<T> getSongPropertyValues(String propertyName, List<T> valueList)
All possible values for a given property.- Parameters:
propertyName
- propertyvalueList
- list that this method will add the results to. Before the results are added, the list is cleared.- Returns:
- values for a given property
-
getSongPropertyValues
<T> List<T> getSongPropertyValues(String propertyName, String restrictionPropertyName, Object restrictionPropertyValue)
Gets all property values of propertypropertyName
for songs withrestrictionPropertyName
equalingrestrictionPropertyValue
.- Parameters:
propertyName
- properties whose values are going to be returnedrestrictionPropertyName
- property that is used to select the return setrestrictionPropertyValue
- property value that is used to select the return set- Returns:
- values of propertyName
-
getDuplicateTitles
List<String> getDuplicateTitles()
Returns a list of titles that have exact duplicates.- Returns:
- list of duplicate titles
- See Also:
getSimilarTitles()
-
getDuplicateTrackIds
List<String> getDuplicateTrackIds()
Returns a list of track ids that correspond to more than one song.- Returns:
- list of duplicate ids
- See Also:
getSimilarTitles()
-
getAcousticallyIdenticalSongIds
Set<Set<Long>> getAcousticallyIdenticalSongIds(Set<Long> ids)
Returns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])
) can be found.- Parameters:
ids
- ids of the the songs to find duplicates for- Returns:
- set of id sets
- See Also:
getAcousticallyIdenticalSongIds(Set, int)
-
getAcousticallyIdenticalSongIds
Set<Set<Long>> getAcousticallyIdenticalSongIds(Set<Long> ids, int maxSubprintMatchAttempts)
Returns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])
) can be found.- Parameters:
ids
- ids of the the songs to find duplicates formaxSubprintMatchAttempts
- maximum number of attempts to match a subprint. Negative values cause an exhaustive search (longer runtime). The default value used ingetAcousticallyIdenticalSongIds()
is15
.- Returns:
- set of id sets
- See Also:
getAcousticallyIdenticalSongIds()
-
getAcousticallyIdenticalSongIds
@Deprecated Set<Set<Long>> getAcousticallyIdenticalSongIds(int maxSubprintMatchAttempts)
Deprecated.Returns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])
) can be found. Because of scalability issues, please usegetAcousticallyIdenticalSongIds(Set, int)
.- Parameters:
maxSubprintMatchAttempts
- maximum number of attempts to match a subprint. Negative values cause an exhaustive search (longer runtime). The default value used ingetAcousticallyIdenticalSongIds()
is15
.- Returns:
- set of id sets
- See Also:
getAcousticallyIdenticalSongIds(Set, int)
-
getAcousticallyIdenticalSongIds
@Deprecated Set<Set<Long>> getAcousticallyIdenticalSongIds()
Deprecated.Returns a collection of sets that each contain song ids of acoustically "identical" songs. Only songs that have fingerprints (seeAudioSong.setFingerprint(byte[])
) can be found. Because of scalability issues, please usegetAcousticallyIdenticalSongIds(Set)
.- Returns:
- set of id sets
- See Also:
getAcousticallyIdenticalSongIds(Set)
-
getSimilarTitles
Collection<Set<Long>> getSimilarTitles()
Returns a collection of id sets that point to songs with similar or identical titles.- Returns:
- collection of id sets
- See Also:
getDuplicateTitles()
-
getLibrary
PlayList getLibrary()
Returns the master playlist that contains all library objects. This may also be unexpected objects like apps. For just Music objects, get the playlist with kindPlayList.Kind.MUSIC
(testable viaPlayList.getDistinguishedKind()
).- Returns:
- master playlist
-
getPlayLists
List<PlayList> getPlayLists()
List of all playlists.- Returns:
- list of all playlists in the library
-
getPlayList
PlayList getPlayList(long playListPersistentId)
Get aPlayList
for an id.- Parameters:
playListPersistentId
- persistent id- Returns:
- the playlist corresponding to the id or null, if it does not exist
-
createPlayList
PlayList createPlayList(Long parentId, String name)
Creates a new PlayList at a specific location.- Parameters:
parentId
- persistent id of the parent, i.e. the location of the playlist to newly createname
- name- Returns:
- new playlist object.
-
createPlayList
PlayList createPlayList(String name)
Creates a new PlayList under the Music playlist/folder.- Parameters:
name
- name- Returns:
- new playlist object.
-
createFolder
PlayList createFolder(Long parentId)
Creates a new folder at a specific location.- Parameters:
parentId
- persistent id of the parent, i.e. the location of the folder to newly create- Returns:
- new folder object.
-
createFolder
PlayList createFolder()
Creates a new folder under the Music playlist/folder.- Returns:
- new folder object.
-
createPlayList
PlayList createPlayList(Long id, Long parentId, String name, boolean folder)
Creates a newPlayList
object with the given name and id.- Parameters:
id
- persistentIdparentId
- parent playlist persistent id - may benull
, if there is no parentname
- namefolder
- is folder- Returns:
- a new persistent playlist
-
getAlbum
@Deprecated Album getAlbum(Album.Key key)
Deprecated.Returns an album. The songs contained in this album are not properly wrapped. Writing to them most likely does not work as expected.- Parameters:
key
- album key, interpreted case-insensitively- Returns:
- album
- See Also:
getAlbumSongs(String, String)
-
getAlbumSongIds
List<Long> getAlbumSongIds(String album, String artist)
Returns a list of song ids for songs specified by the given album and artist. At least on of the two parameters must be a non-empty string. The lookup is case-sensitive. To find valid album/artist combinations, checkgetAlbumKeys()
.- Parameters:
album
- albumartist
- artist or album artist- Returns:
- list of ids
- See Also:
getAlbumSongs(String, String)
,getAlbumKeys()
-
getAlbumSongs
List<AudioSong> getAlbumSongs(String album, String artist)
Returns a list of songs specified by the given album and artist. At least one of the two parameters must be a non-empty string. The lookup is case-sensitive. To find valid album/artist combinations, checkgetAlbumKeys()
.- Parameters:
album
- albumartist
- artist or album artist- Returns:
- list of songs
- See Also:
getAlbumSongIds(String, String)
,getAlbumKeys()
-
getAlbumKeys
Set<Album.Key> getAlbumKeys()
Returns the set of all valid album keys. To qualify for the set, both an album and either an artist or an album artist must be set.- Returns:
- album keys
-
getSongsWithFileAndSize
@Deprecated List<AudioSong> getSongsWithFileAndSize(String filename, int size)
Deprecated.
-
getSongsWithNameArtistAlbumTotalTime
@Deprecated List<AudioSong> getSongsWithNameArtistAlbumTotalTime(String name, String artist, String album, int time)
Deprecated.
-
getSongsWithTrackIdTotalTime
@Deprecated Set<AudioSong> getSongsWithTrackIdTotalTime(Set<AudioId> ids, int time)
Deprecated.
-
countUnprotectedSongsAddedAfter
int countUnprotectedSongsAddedAfter(Date time)
Counts unprotected songs added after a certain date.- Parameters:
time
- time- Returns:
- count
-
getUnprotectedSongsAddedAfter
List<AudioSong> getUnprotectedSongsAddedAfter(Date time)
Return unprotected songs added after a certain date.- Parameters:
time
- time- Returns:
- songs, at most 1000.
-
getPopularTagCollection
TagCollection getPopularTagCollection(int numberOfTags)
Returns theTagCollection
for the X most common tags.- Parameters:
numberOfTags
- max number of tags to return- Returns:
- tag collection for strongest tags in the library
-
getTagCollection
TagCollection getTagCollection()
Returns theTagCollection
for the entire library.- Returns:
- tag collection for the library
-
store
void store(PlayList playList)
Stores a playlist in the beaTunes database.- Parameters:
playList
- playlist to save
-
store
void store(AudioSong song)
Stores a song in the beaTunes database.
The write-process is asynchronous, i.e. this method may return before the songs has actually been written.
- Parameters:
song
- song to save
-
store
void store(AudioSong song, String changedProperty)
Stores a song in the beaTunes database and clears any sortorder caches in the playlist objects this song might be in, if the playlist is sorted by the changed property.
The write-process is asynchronous, i.e. this method may return before the songs has actually been written.
- Parameters:
song
- song to savechangedProperty
- property that has been changed (may be null, if multiple properties have changed or the change is unknown)
-
store
void store(Iterable<AudioSong> songs)
Stores a collection of songs in the beaTunes database.
The write-process is asynchronous, i.e. this method may return before the songs has actually been written.
- Parameters:
songs
- songs to save
-
flushPendingWrites
void flushPendingWrites() throws InterruptedException
Flush any pending writes (blocks until all writes happened).- Throws:
InterruptedException
-
deletePlayList
void deletePlayList(long id)
Deletes a playlist from the library.- Parameters:
id
- id
-
getLastSynchronizationTimestamp
long getLastSynchronizationTimestamp()
Timestamp of last synchronization of the current library.- Returns:
- timestamp or
0
, if unknown
-
getPreviousToLastSynchronizationTimestamp
long getPreviousToLastSynchronizationTimestamp()
Timestamp of the previous to last synchronization of the current library.- Returns:
- timestamp or
0
, if unknown
-
setLibraryDescriptor
void setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
Sets the library descriptor.- Parameters:
libraryDescriptor
- library descriptor
-
getLibraryDescriptor
LibraryDescriptor getLibraryDescriptor()
Returns the library descriptor. Use this method to find out, what kind of library you are dealing with.- Returns:
- library descriptor
- See Also:
ITunesLibraryDescriptor
,FileSystemLibraryDescriptor
-
getApplicationVersion
Version getApplicationVersion()
Returns the iTunes application version as specified in the iTunes Music Library.xml.- Returns:
- iTunes application version
-
getPersistentId
Long getPersistentId()
Returns the iTunes library persistent id as specified in theiTunes Music Library.xml
.- Returns:
- persistent library id as long
-
refresh
void refresh() throws IOException, ParserConfigurationException, SAXException
Reloads all objects that are connected to the music library. If this is the first time we are loading the library, it will be done synchronously. After that it will be done asynchronously.
-
refresh
void refresh(boolean blockingCall, boolean manuallyInitiated, boolean full) throws IOException, ParserConfigurationException, SAXException
Reloads all objects that are connected to the music library.- Parameters:
blockingCall
- flag to indicate whether this call should return right away or not.manuallyInitiated
- indicates whether this refresh was directly triggered by some user actionfull
- flag indicating we should attempt a full synchronization (no shortcuts)- Throws:
IOException
ParserConfigurationException
SAXException
-
cancelSynchronization
void cancelSynchronization()
Cancels any ongoing synchronization.- See Also:
refresh()
,isSynchronizing()
-
isSynchronizing
boolean isSynchronizing()
Indicates, whether we are currently synchronizing.- Returns:
true
orfalse
- See Also:
cancelSynchronization()
-
needsRefresh
boolean needsRefresh() throws IOException
- Returns:
- true, if the library is based on an xml files and was changed. Or if we cannot determine, if a refresh is really necessary
- Throws:
IOException
-
isOneWeekOld
boolean isOneWeekOld() throws IOException
- Returns:
- true if the
iTunes (Music) Library.xml
file is older than one week. - Throws:
IOException
- See Also:
getLibraryDescriptor()
-
addMediaLibraryListener
void addMediaLibraryListener(MediaLibraryListener listener)
-
removeMediaLibraryListener
boolean removeMediaLibraryListener(MediaLibraryListener listener)
-
store
void store(MatchListInfo matchListInfo)
Store the given info.- Parameters:
matchListInfo
- match list info
-
isEmbedAudioMetaData
boolean isEmbedAudioMetaData()
Shall all data be embedded into the audio files, when writing?- Returns:
- true or false
-
setEmbedAudioMetaData
void setEmbedAudioMetaData(boolean embedAudioMetaData)
Shall all data be embedded into audio files or just those fields that are supported by iTunes.- Parameters:
embedAudioMetaData
- embed
-
isForceAudioMetaDataWrites
boolean isForceAudioMetaDataWrites()
Shall new values always be written, even, if the old value seems to be identical? This can happen, when the internal database is out of sync with actual values in audio files or iTunes.- Returns:
- true or false
-
setForceAudioMetaDataWrites
void setForceAudioMetaDataWrites(boolean force)
Shall new values always be written, even, if the old value seems to be identical? This can happen, when the internal database is out of sync with actual values in audio files or iTunes.- Parameters:
force
- force writing
-
setUIDelegate
void setUIDelegate(MediaLibraryUIDelegate uiDelegate)
-
setDatabaseDir
void setDatabaseDir(File databaseDir)
-
getDatabaseDir
File getDatabaseDir()
-
deleteAllFingerprints
void deleteAllFingerprints()
Delete all fingerprints from the database to save disk space.
-
isSupportedPlayList
boolean isSupportedPlayList(PlayList.Kind kind)
Indicates whether a distinguished kind ofPlayList
is supported.- Parameters:
kind
- kind- Returns:
- true or false
-
addPropertyChangeListener
void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
addPropertyChangeListener
void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
-
addPlayListPropertyChangeListener
void addPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Lets you register a listener that receives events when a playlist property is changed. Unlike listeners bound to individual, transient playlist objects, this registration is permanent as long as this library is available.- Parameters:
propertyChangeListener
- listener
-
addPlayListPropertyChangeListener
void addPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Lets you register a listener that receives events when a playlist property is changed. Unlike listeners bound to individual, transient playlist objects, this registration is permanent as long as this library is available.- Parameters:
propertyChangeListener
- listenerproperty
- property
-
removePlayListPropertyChangeListener
void removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
removePlayListPropertyChangeListener
void removePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
-
getPlayListPropertyChangeListeners
PropertyChangeListener[] getPlayListPropertyChangeListeners()
-
getPlayListPropertyChangeListeners
PropertyChangeListener[] getPlayListPropertyChangeListeners(String property)
-
removePropertyChangeListener
void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
removePropertyChangeListener
void removePropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
-
getPropertyChangeListeners
PropertyChangeListener[] getPropertyChangeListeners()
-
getPropertyChangeListeners
PropertyChangeListener[] getPropertyChangeListeners(String property)
-
addPlayListDataListener
void addPlayListDataListener(ListDataListener l)
-
removePlayListDataListener
void removePlayListDataListener(ListDataListener l)
-
-