public interface ITunesMusicLibrary
Music library (despite the name, not specific to iTunes).
In prior versions, this interface returned Song
s instead of AudioSong
s.
Since beaTunes 3, this has been changed. This allows you to simply call setters and not worry about calling
store(com.tagtraum.audiokern.AudioSong, String)
- changes are
persisted automatically in the internal database, iTunes (or whatever other audioplayer, ITunes
)
as well as the file.
PlayList
Modifier and Type | Method and Description |
---|---|
void |
addITunesMusicLibraryListener(ITunesMusicLibraryListener 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) |
int |
countSongs()
Number of songs in the library.
|
int |
countSongsWithPropertyValue(String propertyName,
Object propertyValue)
Count all songs with a property
equal to the given value. |
int |
countUnprotectedSongsAddedAfter(Date time) |
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 new
PlayList 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 |
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()
Returns a collection of sets that each contain song ids of acoustically "identical" songs.
|
Set<Set<Long>> |
getAcousticallyIdenticalSongIds(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.
|
Set<Album.Key> |
getAllTimesFavoriteAlbums(int max) |
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 to
AudioMetaData 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.
|
List<String> |
getGenres() |
Set<Album.Key> |
getHighlyRatedAlbums(int max) |
<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 the
iTunes Music Library.xml . |
PlayList |
getPlayList(long playListPersistentId)
Get a
PlayList for an id. |
PropertyChangeListener[] |
getPlayListPropertyChangeListeners() |
PropertyChangeListener[] |
getPlayListPropertyChangeListeners(String property) |
List<PlayList> |
getPlayLists()
List of all playlists.
|
TagCollection |
getPopularTagCollection(int numberOfTags)
Returns the
TagCollection 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) |
Set<Album.Key> |
getRecentlyAddedAlbums(int max) |
Set<Album.Key> |
getRecentlyPlayedAlbums(int max) |
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 an
Iterable 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 of
PlayList.Kind s. |
List<Long> |
getSongIdsWithoutPropertyValue(String propertyName,
Object propertyValue)
Get all song ids of songs with a property
equal the given value. |
List<Long> |
getSongIdsWithPropertyLikeValue(String propertyName,
String propertyValue)
Get all song ids of songs with a property
like the given value. |
List<Long> |
getSongIdsWithPropertyValue(String propertyName,
Object propertyValue)
Get all song ids for songs with a property
equal to the given value. |
<T> List<T> |
getSongPropertyValues(String propertyName)
All possible values for a given property.
|
<T> List<T> |
getSongPropertyValues(String propertyName,
List<T> valueList)
All possible values for a given property.
|
<T> List<T> |
getSongPropertyValues(String propertyName,
String restrictionPropertyName,
Object restrictionPropertyValue)
Gets all property values of property
propertyName for songs with
restrictionPropertyName equaling restrictionPropertyValue . |
Iterable<AudioSong> |
getSongs()
Returns an
Iterable that can be used to iterate over all songs. |
Iterable<AudioSong> |
getSongs(Collection<Long> ids)
Returns an
Iterable that can be used to iterate over the specified songs. |
List<AudioSong> |
getSongsWithFileAndSize(String filename,
int size)
Deprecated.
|
List<AudioSong> |
getSongsWithNameArtistAlbumTotalTime(String name,
String artist,
String album,
int time)
Deprecated.
|
List<AudioSong> |
getSongsWithoutPropertyValue(String propertyName,
Object propertyValue)
Get all songs with a property
not equal to the given value. |
List<AudioSong> |
getSongsWithPropertyLikeValue(String propertyName,
String propertyValue)
Get all songs with a property
like the given value. |
List<AudioSong> |
getSongsWithPropertyValue(String propertyName,
Object propertyValue)
Get all songs with a property
equal to the given value. |
Set<AudioSong> |
getSongsWithTrackIdTotalTime(Set<AudioId> ids,
int time)
Deprecated.
|
TagCollection |
getTagCollection()
Returns the
TagCollection 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 to
ITunes related tasks. |
List<AudioSong> |
getUnprotectedSongsAddedAfter(Date time) |
void |
init()
Initializes this component and its sub-components.
|
boolean |
isEmbedAudioMetaData() |
boolean |
isNewDatabase() |
boolean |
isOneWeekOld() |
boolean |
isSynchronizing() |
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)
Reloads all objects that are connected to the music library.
|
void |
removePlayListDataListener(ListDataListener l) |
void |
removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
removePlayListPropertyChangeListener(String property,
PropertyChangeListener propertyChangeListener) |
void |
removePropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
removePropertyChangeListener(String property,
PropertyChangeListener propertyChangeListener) |
<V> V |
serialExecute(Callable<V> callable)
Execute the callable with
getTunesExecutor() , but not before
getAudioMetaDataExecutor() has run through. |
void |
serialExecute(Runnable runnable)
Execute the runnable with
getTunesExecutor() , but not before
getAudioMetaDataExecutor() has run through. |
void |
setDatabaseDir(File databaseDir) |
void |
setEmbedAudioMetaData(boolean embedAudioMetaData) |
void |
setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
Sets the library descriptor.
|
void |
setNewDatabase(boolean newDatabase) |
void |
setUIDelegate(MusicLibraryUIDelegate uiDelegate) |
void |
shutdown()
Shuts down this component and its sub-components.
|
<V> V |
smuggle(Callable<V> callable)
Smuggles read-only calls to the
getTunesExecutor() 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(Iterable<AudioSong> songs)
Stores a collection of songs in the beaTunes database.
|
void |
store(MatchListInfo matchListInfo)
Store the given info.
|
void |
store(PlayList playList)
Stores a playlist in the beaTunes database.
|
<T> T getImplementation(Class<T> klass)
void init()
void shutdown() throws ShutdownVetoException
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 itExecutorService getTunesExecutor()
ITunes
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 a
Track
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.
TunesUtilities.getExecutorService()
ExecutorService getAudioMetaDataExecutor()
AudioMetaData
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 a
AudioMetaData
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.
AudioMetaData.getExecutorService()
<V> V serialExecute(Callable<V> callable) throws Exception
getTunesExecutor()
, but not before
getAudioMetaDataExecutor()
has run through.V
- return typecallable
- callableException
void serialExecute(Runnable runnable)
getTunesExecutor()
, but not before
getAudioMetaDataExecutor()
has run through.runnable
- runnable<V> V smuggle(Callable<V> callable) throws Exception
getTunesExecutor()
even when it's blocked.V
- return typecallable
- callableException
ReentrantLock getLock(Long songId)
songId
- song idLock lock(Long songId)
songId
- song idITunes getTunes()
boolean isNewDatabase()
void setNewDatabase(boolean newDatabase)
int countSongs()
int countSongsWithPropertyValue(String propertyName, Object propertyValue)
equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertyList<AudioSong> getSongsWithPropertyValue(String propertyName, Object propertyValue)
equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertyList<Long> getSongIdsWithPropertyValue(String propertyName, Object propertyValue)
equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertyList<AudioSong> getSongsWithoutPropertyValue(String propertyName, Object propertyValue)
not equal
to the given value.propertyName
- name of a propertypropertyValue
- value of a propertygetSongIdsWithoutPropertyValue(String, Object)
List<Long> getSongIdsWithoutPropertyValue(String propertyName, Object propertyValue)
equal
the given value.propertyName
- name of a propertypropertyValue
- value of a propertygetSongsWithoutPropertyValue(String, Object)
List<AudioSong> getSongsWithPropertyLikeValue(String propertyName, String propertyValue)
like
the given value.propertyName
- name of a propertypropertyValue
- value of a string propertygetSongIdsWithPropertyLikeValue(String, String)
List<Long> getSongIdsWithPropertyLikeValue(String propertyName, String propertyValue)
like
the given value.propertyName
- name of a propertypropertyValue
- value of a string propertygetSongsWithPropertyLikeValue(String, String)
Iterable<AudioSong> getSongs()
Iterable
that can be used to iterate over all songs.
Shortcut for getLibrary().getSongs().
Note that the Iterable may be a List, which would expose other means
of dealing with the content.Iterable<AudioSong> getSongs(Collection<Long> ids)
Iterable
that can be used to iterate over the specified songs.ids
- collection of idsList<Long> getSongIds()
Iterable
that can be used to iterate over all song ids.Set<Long> getSongIds(PlayList.Kind... kinds)
PlayList.Kind
s.kinds
- kindAudioSong getSong(Long id)
Song.getId()
.id
- idnull
, if not foundAudioSong fetchCollections(AudioSong song)
song
- song to 'complete'<T> List<T> getSongPropertyValues(String propertyName)
propertyName
- property<T> List<T> getSongPropertyValues(String propertyName, List<T> valueList)
propertyName
- propertyvalueList
- list that this method will add the results to.
Before the results are added, the list is cleared.<T> List<T> getSongPropertyValues(String propertyName, String restrictionPropertyName, Object restrictionPropertyValue)
propertyName
for songs with
restrictionPropertyName
equaling restrictionPropertyValue
.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 setList<String> getDuplicateTitles()
getSimilarTitles()
List<String> getDuplicateTrackIds()
getSimilarTitles()
Set<Set<Long>> getAcousticallyIdenticalSongIds()
AudioSong.setFingerprint(byte[])
) can be found.getAcousticallyIdenticalSongIds(int)
Set<Set<Long>> getAcousticallyIdenticalSongIds(int maxSubprintMatchAttempts)
AudioSong.setFingerprint(byte[])
) can be found.maxSubprintMatchAttempts
- maximum number of attempts to match a subprint.
Negative values cause an exhaustive search (longer runtime).
The default value used in getAcousticallyIdenticalSongIds()
is 15
.getAcousticallyIdenticalSongIds()
Collection<Set<Long>> getSimilarTitles()
getDuplicateTitles()
PlayList getLibrary()
PlayList.Kind.MUSIC
(testable via PlayList.getDistinguishedKind()
).List<PlayList> getPlayLists()
PlayList getPlayList(long playListPersistentId)
PlayList
for an id.playListPersistentId
- persistent idPlayList createPlayList(Long parentId, String name)
parentId
- persistent id of the parent, i.e. the location of the playlist to newly createname
- namePlayList createPlayList(String name)
name
- namePlayList createFolder(Long parentId)
parentId
- persistent id of the parent, i.e. the location of the folder to newly createPlayList createFolder()
PlayList createPlayList(Long id, Long parentId, String name, boolean folder)
PlayList
object with the given name and id.id
- persistentIdparentId
- parent playlist persistent id - may be null
, if there is no parentname
- namefolder
- is folder@Deprecated Album getAlbum(Album.Key key)
key
- album key, interpreted case-insensitivelygetAlbumSongs(String, String)
List<Long> getAlbumSongIds(String album, String artist)
getAlbumKeys()
.album
- albumartist
- artist or album artistgetAlbumSongs(String, String)
,
getAlbumKeys()
List<AudioSong> getAlbumSongs(String album, String artist)
getAlbumKeys()
.album
- albumartist
- artist or album artistgetAlbumSongIds(String, String)
,
getAlbumKeys()
Set<Album.Key> getAlbumKeys()
@Deprecated List<AudioSong> getSongsWithFileAndSize(String filename, int size)
@Deprecated List<AudioSong> getSongsWithNameArtistAlbumTotalTime(String name, String artist, String album, int time)
@Deprecated Set<AudioSong> getSongsWithTrackIdTotalTime(Set<AudioId> ids, int time)
int countUnprotectedSongsAddedAfter(Date time)
TagCollection getPopularTagCollection(int numberOfTags)
TagCollection
for the X most common tags.numberOfTags
- max number of tags to returnTagCollection getTagCollection()
TagCollection
for the entire library.void store(PlayList playList)
playList
- playlist to savevoid 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.
song
- song to savevoid 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.
song
- song to savechangedProperty
- property that has been changed (may be null, if multiple properties have changed or the change is unknown)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.
songs
- songs to savevoid flushPendingWrites() throws InterruptedException
InterruptedException
void deletePlayList(long id)
id
- idlong getLastSynchronizationTimestamp()
0
, if unknownlong getPreviousToLastSynchronizationTimestamp()
0
, if unknownvoid setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
libraryDescriptor
- library descriptorLibraryDescriptor getLibraryDescriptor()
ITunesLibraryDescriptor
,
FileSystemLibraryDescriptor
Version getApplicationVersion()
Long getPersistentId()
iTunes Music Library.xml
.void refresh() throws IOException, ParserConfigurationException, SAXException
void refresh(boolean blockingCall, boolean manuallyInitiated) throws IOException, ParserConfigurationException, SAXException
blockingCall
- flag to indicate whether this call should return right away or not.manuallyInitiated
- indicates whether this refresh was directly triggered by some user actionIOException
ParserConfigurationException
SAXException
boolean needsRefresh()
boolean isOneWeekOld()
iTunes (Music) Library.xml
file is older than one week.getLibraryDescriptor()
void addITunesMusicLibraryListener(ITunesMusicLibraryListener listener)
void store(MatchListInfo matchListInfo)
matchListInfo
- match list infoboolean isEmbedAudioMetaData()
void setEmbedAudioMetaData(boolean embedAudioMetaData)
void setUIDelegate(MusicLibraryUIDelegate uiDelegate)
void setDatabaseDir(File databaseDir)
File getDatabaseDir()
void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
void addPlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
propertyChangeListener
- listenervoid addPlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
propertyChangeListener
- listenerproperty
- propertyvoid removePlayListPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void removePlayListPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
PropertyChangeListener[] getPlayListPropertyChangeListeners()
PropertyChangeListener[] getPlayListPropertyChangeListeners(String property)
void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
void removePropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener[] getPropertyChangeListeners(String property)
void addPlayListDataListener(ListDataListener l)
void removePlayListDataListener(ListDataListener l)
boolean isSynchronizing()
Copyright © 2006–2017 tagtraum industries incorporated. All rights reserved.