public abstract class AbstractMusicLibrary<T extends ApplicationComponent> extends Object implements ITunesMusicLibrary, ApplicationComponent<T>
Modifier and Type | Field and Description |
---|---|
static boolean |
AUTO_DETECT_ITUNESLIBRARY |
protected File |
databaseDir |
protected PropertyChangeSupport |
propertyChangeSupport |
protected static long |
TEN_MINUTES |
protected static int |
TOTALTIME_DEVIATION |
protected ITunesMusicLibrary |
wrappingProxy |
Modifier | Constructor and Description |
---|---|
protected |
AbstractMusicLibrary(T application) |
Modifier and Type | Method and Description |
---|---|
void |
addITunesMusicLibraryListener(ITunesMusicLibraryListener listener) |
void |
addPropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
addPropertyChangeListener(String property,
PropertyChangeListener propertyChangeListener) |
protected void |
fireAsynchronousSynchronizationEvent() |
protected void |
fireLibrarySynchronizedEvent() |
protected void |
fireSynchronousSynchronizationEvent() |
T |
getApplication()
Returns the main application component.
|
ExecutorService |
getAudioMetaDataExecutor()
Returns en executor service that should be used for any write access to
AudioMetaData related tasks. |
<T> T |
getImplementation(Class<T> klass) |
long |
getLastSynchronizationTimestamp()
Timestamp of last synchronization of the current library.
|
LibraryDescriptor |
getLibraryDescriptor()
Returns the library descriptor.
|
protected abstract LibraryLoader |
getLibraryLoader() |
ReentrantLock |
getLock(Long songId)
Provides a lock object for a song id.
|
PlayList |
getPlayList(long id)
Get a
PlayList for an id. |
long |
getPreviousToLastSynchronizationTimestamp()
Timestamp of the previous to last synchronization of the current library.
|
PropertyChangeListener[] |
getPropertyChangeListeners() |
PropertyChangeListener[] |
getPropertyChangeListeners(String property) |
Set<Long> |
getSongIds(PlayList.Kind... kinds)
Returns all ids that are in the given set of
PlayList.Kind s. |
Iterable<AudioSong> |
getSongs()
Returns an
Iterable that can be used to iterate over all songs. |
ITunes |
getTunes()
Returns the currently associated audio player, probably iTunes.
|
MultiQueueExecutor |
getTunesExecutor()
Returns en executor service that should be used for any write access to
ITunes related tasks. |
MusicLibraryUIDelegate |
getUIDelegate() |
ITunesMusicLibrary |
getWrappingProxy() |
WrappingProxyFactory |
getWrappingProxyFactory() |
boolean |
isEmbedAudioMetaData() |
boolean |
isNewDatabase() |
boolean |
isOneWeekOld() |
protected abstract boolean |
isProgressDialogVisible(boolean firstTime,
boolean manuallyInitiated) |
boolean |
isRebuildPlayLists() |
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 |
refreshOnNextUpdate() |
void |
removePropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
removePropertyChangeListener(String property,
PropertyChangeListener propertyChangeListener) |
<V> V |
serialExecute(Callable<V> callable)
Execute the callable with
ITunesMusicLibrary.getTunesExecutor() , but not before
ITunesMusicLibrary.getAudioMetaDataExecutor() has run through. |
void |
serialExecute(Runnable runnable)
Execute the runnable with
ITunesMusicLibrary.getTunesExecutor() , but not before
ITunesMusicLibrary.getAudioMetaDataExecutor() has run through. |
void |
setApplication(T application)
Sets the main application component.
|
void |
setDatabaseDir(File databaseDir) |
void |
setEmbedAudioMetaData(boolean embedAudioMetaData) |
void |
setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
Sets the library descriptor.
|
void |
setNewDatabase(boolean newDatabase) |
void |
setRebuildPlayLists(boolean rebuildPlayLists)
If set to true, the library will attempt to re-build all playlists on next
load(boolean, boolean) . |
void |
setUIDelegate(MusicLibraryUIDelegate uiDelegate) |
<V> V |
smuggle(Callable<V> callable)
Smuggles read-only calls to the
ITunesMusicLibrary.getTunesExecutor() even when it's blocked. |
void |
store(AudioSong song)
Stores a song in the beaTunes database.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPlayListDataListener, addPlayListPropertyChangeListener, addPlayListPropertyChangeListener, countSongs, countSongsWithPropertyValue, countUnprotectedSongsAddedAfter, createFolder, createFolder, createPlayList, createPlayList, createPlayList, deletePlayList, fetchCollections, flushPendingWrites, getAcousticallyIdenticalSongIds, getAcousticallyIdenticalSongIds, getAlbum, getAlbumKeys, getAlbumSongIds, getAlbumSongs, getAllTimesFavoriteAlbums, getApplicationVersion, getDatabaseDir, getDuplicateTitles, getDuplicateTrackIds, getGenres, getHighlyRatedAlbums, getLibrary, getPersistentId, getPlayListPropertyChangeListeners, getPlayListPropertyChangeListeners, getPlayLists, getPopularTagCollection, getRecentlyAddedAlbums, getRecentlyPlayedAlbums, getSimilarTitles, getSong, getSongIds, getSongIdsWithoutPropertyValue, getSongIdsWithPropertyLikeValue, getSongIdsWithPropertyValue, getSongPropertyValues, getSongPropertyValues, getSongPropertyValues, getSongs, getSongsWithFileAndSize, getSongsWithNameArtistAlbumTotalTime, getSongsWithoutPropertyValue, getSongsWithPropertyLikeValue, getSongsWithPropertyValue, getSongsWithTrackIdTotalTime, getTagCollection, getUnprotectedSongsAddedAfter, init, removePlayListDataListener, removePlayListPropertyChangeListener, removePlayListPropertyChangeListener, shutdown, store, store, store, store
getId, init, shutdown
public static final boolean AUTO_DETECT_ITUNESLIBRARY
protected static final long TEN_MINUTES
protected static final int TOTALTIME_DEVIATION
protected PropertyChangeSupport propertyChangeSupport
protected File databaseDir
protected final ITunesMusicLibrary wrappingProxy
protected AbstractMusicLibrary(T application)
public WrappingProxyFactory getWrappingProxyFactory()
public ITunesMusicLibrary getWrappingProxy()
public MusicLibraryUIDelegate getUIDelegate()
public void setUIDelegate(MusicLibraryUIDelegate uiDelegate)
setUIDelegate
in interface ITunesMusicLibrary
public boolean isEmbedAudioMetaData()
isEmbedAudioMetaData
in interface ITunesMusicLibrary
public void setEmbedAudioMetaData(boolean embedAudioMetaData)
setEmbedAudioMetaData
in interface ITunesMusicLibrary
public ITunes getTunes()
ITunesMusicLibrary
getTunes
in interface ITunesMusicLibrary
public T getApplication()
ApplicationComponent
getApplication
in interface ApplicationComponent<T extends ApplicationComponent>
public <T> T getImplementation(Class<T> klass)
getImplementation
in interface ITunesMusicLibrary
public void setApplication(T application)
ApplicationComponent
setApplication
in interface ApplicationComponent<T extends ApplicationComponent>
application
- main application componentpublic ReentrantLock getLock(Long songId)
ITunesMusicLibrary
getLock
in interface ITunesMusicLibrary
songId
- song idpublic Lock lock(Long songId)
ITunesMusicLibrary
lock
in interface ITunesMusicLibrary
songId
- song idpublic MultiQueueExecutor getTunesExecutor()
ITunesMusicLibrary
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.
getTunesExecutor
in interface ITunesMusicLibrary
TunesUtilities.getExecutorService()
public ExecutorService getAudioMetaDataExecutor()
ITunesMusicLibrary
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.
getAudioMetaDataExecutor
in interface ITunesMusicLibrary
AudioMetaData.getExecutorService()
public <V> V serialExecute(Callable<V> callable) throws Exception
ITunesMusicLibrary
ITunesMusicLibrary.getTunesExecutor()
, but not before
ITunesMusicLibrary.getAudioMetaDataExecutor()
has run through.serialExecute
in interface ITunesMusicLibrary
V
- return typecallable
- callableException
public void serialExecute(Runnable runnable)
ITunesMusicLibrary
ITunesMusicLibrary.getTunesExecutor()
, but not before
ITunesMusicLibrary.getAudioMetaDataExecutor()
has run through.serialExecute
in interface ITunesMusicLibrary
runnable
- runnablepublic <V> V smuggle(Callable<V> callable) throws Exception
ITunesMusicLibrary
ITunesMusicLibrary.getTunesExecutor()
even when it's blocked.smuggle
in interface ITunesMusicLibrary
V
- return typecallable
- callableException
public boolean isNewDatabase()
isNewDatabase
in interface ITunesMusicLibrary
public void setNewDatabase(boolean newDatabase)
setNewDatabase
in interface ITunesMusicLibrary
public Iterable<AudioSong> getSongs()
ITunesMusicLibrary
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.getSongs
in interface ITunesMusicLibrary
public Set<Long> getSongIds(PlayList.Kind... kinds)
ITunesMusicLibrary
PlayList.Kind
s.getSongIds
in interface ITunesMusicLibrary
kinds
- kindpublic boolean isRebuildPlayLists()
public void setRebuildPlayLists(boolean rebuildPlayLists)
load(boolean, boolean)
.
This makes primarily sense for iTunes based libraries. The load/sync itself is not triggered
automatically.rebuildPlayLists
- true, if you want to trigger a rebuild.public PlayList getPlayList(long id)
ITunesMusicLibrary
PlayList
for an id.getPlayList
in interface ITunesMusicLibrary
id
- persistent idprotected abstract LibraryLoader getLibraryLoader()
public long getLastSynchronizationTimestamp()
ITunesMusicLibrary
getLastSynchronizationTimestamp
in interface ITunesMusicLibrary
0
, if unknownpublic long getPreviousToLastSynchronizationTimestamp()
ITunesMusicLibrary
getPreviousToLastSynchronizationTimestamp
in interface ITunesMusicLibrary
0
, if unknownpublic void setLibraryDescriptor(LibraryDescriptor libraryDescriptor)
ITunesMusicLibrary
setLibraryDescriptor
in interface ITunesMusicLibrary
libraryDescriptor
- library descriptorpublic LibraryDescriptor getLibraryDescriptor()
ITunesMusicLibrary
getLibraryDescriptor
in interface ITunesMusicLibrary
ITunesLibraryDescriptor
,
FileSystemLibraryDescriptor
public void refresh() throws IOException, ParserConfigurationException, SAXException
ITunesMusicLibrary
refresh
in interface ITunesMusicLibrary
IOException
ParserConfigurationException
SAXException
public void refresh(boolean blockingCall, boolean manuallyInitiated) throws IOException, ParserConfigurationException, SAXException
ITunesMusicLibrary
refresh
in interface ITunesMusicLibrary
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
public void refreshOnNextUpdate()
public boolean needsRefresh()
needsRefresh
in interface ITunesMusicLibrary
public boolean isOneWeekOld()
isOneWeekOld
in interface ITunesMusicLibrary
iTunes (Music) Library.xml
file is older than one week.ITunesMusicLibrary.getLibraryDescriptor()
protected abstract boolean isProgressDialogVisible(boolean firstTime, boolean manuallyInitiated)
public boolean isSynchronizing()
isSynchronizing
in interface ITunesMusicLibrary
public void addITunesMusicLibraryListener(ITunesMusicLibraryListener listener)
addITunesMusicLibraryListener
in interface ITunesMusicLibrary
protected void fireLibrarySynchronizedEvent()
protected void fireSynchronousSynchronizationEvent()
protected void fireAsynchronousSynchronizationEvent()
public void setDatabaseDir(File databaseDir)
setDatabaseDir
in interface ITunesMusicLibrary
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
addPropertyChangeListener
in interface ITunesMusicLibrary
public void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
addPropertyChangeListener
in interface ITunesMusicLibrary
public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
removePropertyChangeListener
in interface ITunesMusicLibrary
public void removePropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
removePropertyChangeListener
in interface ITunesMusicLibrary
public PropertyChangeListener[] getPropertyChangeListeners()
getPropertyChangeListeners
in interface ITunesMusicLibrary
public PropertyChangeListener[] getPropertyChangeListeners(String property)
getPropertyChangeListeners
in interface ITunesMusicLibrary
public void store(AudioSong song)
ITunesMusicLibrary
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.
store
in interface ITunesMusicLibrary
song
- song to saveCopyright © 2006–2017 tagtraum industries incorporated. All rights reserved.