Package com.tagtraum.audiokern
Interface PlayList
-
- All Superinterfaces:
ListModel,SyncTempoAware
- All Known Implementing Classes:
AmazonPlayList,BeatportPlayList,FileSystemPlayList,HibernatePlayList,ITunesPlayList,PlayListFacade,ReadOnlyPlayList
public interface PlayList extends ListModel, SyncTempoAware
Playlist consisting of a number ofAudioSongs.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classPlayList.KindKinds of playlists.static classPlayList.SortDirectionSort direction.static classPlayList.SubstringFilterPropertyProperties to filter by, when using the sub-string filter.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener propertyChangeListener)Add a listener.voidaddPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)Add a listener for a specific property.voidaddSongIds(int filteredIndex, List<Long> songIds)Adds the given songs at the given (filtered) index.voidaddSongIds(List<Long> songIds)Adds the songs referenced by the given ids to this playlist.voidaddSongs(int filteredIndex, String... locations)Adds songs to the playlist using only their locations.
Depending on the library implementation, the insert index may be ignored.voidaddSongs(int filteredIndex, List<AudioSong> songs)Adds the given songs at the given (filtered) index.booleancanAddItem()Indicates whether we can add items to this playlist.booleancanInsertItem()Indicates whether we can insert items into this playlist.default booleancontains(AudioSong song)booleancontains(Long id)intcountSongs(Collection<? extends SongFilter> filters)Returns song count from this playlist, filtered with the given filters.int[]filteredIndices(int... unfilteredIndices)Returns the filtered indices (string, order) for the given unfiltered indices.PlayListIterator<AudioSong>filteredListIterator(int startIndex)Creates a dynamically updated iterator for this playlist.List<PlayList>getChildPlayLists()StringgetDescription()PlayList.KindgetDistinguishedKind()Returns the special kind of this playlist.longgetFileSize()Get the sum of all file sizes (with filters applied).List<Long>getFilteredSongIds()Returns song ids from this playlist, both sorted and filtered.Iterable<AudioSong>getFilteredSongs()Returns songs from this playlist, both sorted and filtered.intgetGeniusTrackID()LonggetId()This list's id.LonggetIdAt(int index)Returns id of the song at the given index, taking sorting and filtering into account.<T> TgetImplementation(Class<T> klass)PlayListobjects are sometimes implemented by an object that acts as a facade to other objects.IndexedId[]getIndexedSongIds()A complete list of sorted ids along with their natural order indices (viaIndexedId.getIndex()).AudioSong.LikinggetLiking()StringgetName()LonggetParentId()If this is a sub-folder/playlist, this returns the parent id.PlayListgetParentPlayList()PlayList[]getPlayListPath()Returns path leading to this playlist and ending with it.StringgetSmartCriteria()StringgetSmartInfo()AudioSonggetSong(int index)Returns song from the given index, taking sorting and filtering into account.List<Long>getSongIds()Returns song ids from this playlist, neither sorted not filtered.List<Long>getSongIds(Set<? extends SongFilter> filters)Returns song ids from this playlist, filtered with the given filters.Iterable<AudioSong>getSongs()Returns songs from this playlist, neither sorted nor filtered.List<AudioSong>getSongs(Collection<? extends SongFilter> filters, int limit)Returns songs from this playlist, filtered with the given filters.default Iterable<AudioSong>getSongsOrderedBy(String sortProperty)Returns anIterablethat can be used to iterate over all songs.Iterable<AudioSong>getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)Returns songs from this playlist, sorted by the given property.Iterable<AudioSong>getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)Returns songs from this playlist, sorted by the given property.StringgetSortColumnProperty()Returns the name of the single property the playlist is sorted by.PlayList.SortDirectiongetSortDirection()Return sort direction.String[]getSortProperties()Actual sort properties, used inORDER BYHQL/SQL clauses.StringgetSortProperty(int index)Actual sort property, used inORDER BYSQL clauses.SpecialPlayListInfogetSpecialPlayListInfo()LonggetSpecialPlayListInfoId()StringgetSubstringFilter()Current substring filter.PlayList.SubstringFilterPropertygetSubstringFilterProperty()Current property to filter.com.tagtraum.audiokern.bpm.TempogetSyncTempo()When set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo.longgetTotalTime()Get time with filters applied.intgetUnfilteredSize()Unfiltered number of songs in playlist.longgetUnfilteredTime()Get time without any filters applied.default intindexOf(AudioSong song)Returns the first index of the given song.intindexOf(Long id)Returns the first index of the given song.booleanisAggregateDataAvailable()Indicates whether we currently have valid aggregate (total size, duration, etc.) data.booleanisAllItems()booleanisAudiobooks()booleanisEditable()Is this playlist editable? Only playlists created by users are editable.booleanisFolder()booleanisGeniusPlaylist()booleanisItemsEditable()Are the contained items editable? E.g., items are not editable, if they are only available online, as the metadata of some stream or online database cannot be changed locally.booleanisLibrary()Indicates that this is a library playlist, meaning one of the top level library views (e.g.booleanisMaster()Indicates whether this playlist is a master playlist.booleanisMovies()booleanisMusic()booleanisParentAFolder()booleanisPodcasts()booleanisPurchasedMusic()booleanisSmartPlaylist()booleanisSpecialPlayList()booleanisTvShows()booleanisUserPlaylist()Indicates that the playlist is just a regular user playlist.booleanisVideos()Deprecated.intmoveSongs(int[] fromIndices, int toIndex)Moves songs.voidremoveAllSongs()Removes all songs from this playlist.voidremovePropertyChangeListener(PropertyChangeListener propertyChangeListener)Remove a listener.booleanremoveSongs(int... filteredIndex)Removes the song with the given (filtered) index from the playlist.default booleanremoveSongs(Collection<Long> ids)Removes the songs with the given ids from the list.booleanremoveSongs(Collection<Long> ids, boolean completelyDeleteSong)Removes the songs with the given ids from the list.voidsetAllItems(boolean allItems)voidsetAudiobooks(boolean audiobooks)voidsetChildPlayLists(List<PlayList> childPlayLists)voidsetDescription(String description)voidsetDistinguishedKind(PlayList.Kind distinguishedKind)Allows setting of a special song type, likePlayList.Kind.PODCASTS.voidsetFolder(boolean folder)voidsetGeniusTrackID(int geniusTrackID)voidsetId(Long id)Sets this list's id.voidsetLiking(AudioSong.Liking liking)voidsetMaster(boolean master)voidsetMovies(boolean movies)voidsetMusic(boolean music)voidsetName(String name)voidsetParentId(Long parentId)Sets the parent id.voidsetParentPlayList(PlayList parentPlayList)voidsetPodcasts(boolean podcasts)voidsetPurchasedMusic(boolean purchasedMusic)voidsetSmartCriteria(String smartCriteria)voidsetSmartInfo(String smartInfo)voidsetSongIds(List<Long> songIds)Removes all songs from this playlist and replaces them with song connected to the given ids.voidsetSongs(List<AudioSong> songs)Removes all songs from this playlist and replaces them with the given songs.voidsetSortColumnProperty(String property)Sets "visual/semantic" sort property.voidsetSortDirection(PlayList.SortDirection sortDirection)Sort direction.voidsetSortProperties(String... properties)Sets sort properties.voidsetSpecialPlayListInfo(SpecialPlayListInfo specialPlayListInfo)voidsetSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)Sets the filter and which property to filter in one swoop.voidsetSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)When set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo.voidsetTvShows(boolean tvShows)voidsetVideos(boolean videos)Deprecated.int[]unfilteredIndices(int... filteredIndices)Returns the unfiltered indices for the given filtered (string, order) indices.-
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
-
-
-
-
Method Detail
-
getImplementation
<T> T getImplementation(Class<T> klass)
PlayListobjects are sometimes implemented by an object that acts as a facade to other objects. For example, this could be a proxy for an AppleScript iTunes object or a persistent object that is stored in a local database via Hibernate. While normal calls to an object implementing this interface are routed according to some internal logic, using one of the actual implementation classes allows you precise control over what your call does.Note to plugin developers: It is hardly ever a good idea to exercise this control, unless you know exactly what you are doing. :-)
- Type Parameters:
T- implementation class- Parameters:
klass- class implementing PlayList- Returns:
- object of the desired type or
null, if such an object is not available - See Also:
AudioSong.getImplementation(Class)
-
removePropertyChangeListener
void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Remove a listener.- Parameters:
propertyChangeListener- listener
-
addPropertyChangeListener
void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Add a listener.- Parameters:
propertyChangeListener- listener
-
addPropertyChangeListener
void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Add a listener for a specific property.- Parameters:
propertyChangeListener- listener
-
getId
Long getId()
This list's id.- Returns:
- id
-
setId
void setId(Long id)
Sets this list's id.- Parameters:
id- id
-
getParentId
Long getParentId()
If this is a sub-folder/playlist, this returns the parent id.- Returns:
- id
-
setParentId
void setParentId(Long parentId)
Sets the parent id.- Parameters:
parentId- id
-
getSpecialPlayListInfo
SpecialPlayListInfo getSpecialPlayListInfo()
-
getSpecialPlayListInfoId
Long getSpecialPlayListInfoId()
-
setSpecialPlayListInfo
void setSpecialPlayListInfo(SpecialPlayListInfo specialPlayListInfo)
-
isSpecialPlayList
boolean isSpecialPlayList()
-
getDistinguishedKind
PlayList.Kind getDistinguishedKind()
Returns the special kind of this playlist.- Returns:
nullif unknown
-
setDistinguishedKind
void setDistinguishedKind(PlayList.Kind distinguishedKind)
Allows setting of a special song type, likePlayList.Kind.PODCASTS.- Parameters:
distinguishedKind- kind
-
isAudiobooks
boolean isAudiobooks()
-
setAudiobooks
void setAudiobooks(boolean audiobooks)
-
isMovies
boolean isMovies()
-
setMovies
void setMovies(boolean movies)
-
isMusic
boolean isMusic()
-
setMusic
void setMusic(boolean music)
-
isTvShows
boolean isTvShows()
-
setTvShows
void setTvShows(boolean tvShows)
-
isPodcasts
boolean isPodcasts()
-
setPodcasts
void setPodcasts(boolean podcasts)
-
getParentPlayList
PlayList getParentPlayList()
-
setParentPlayList
void setParentPlayList(PlayList parentPlayList)
-
getPlayListPath
PlayList[] getPlayListPath()
Returns path leading to this playlist and ending with it. I.e., the path has at least the length 1.- Returns:
- path of playlists
-
getName
String getName()
-
setName
void setName(String name)
-
getDescription
String getDescription()
-
setDescription
void setDescription(String description)
-
getLiking
AudioSong.Liking getLiking()
-
setLiking
void setLiking(AudioSong.Liking liking)
-
isMaster
boolean isMaster()
Indicates whether this playlist is a master playlist. E.g. the (invisible list) Library is typically the master playlist.- Returns:
- true or false
- See Also:
isLibrary()
-
setMaster
void setMaster(boolean master)
-
isLibrary
boolean isLibrary()
Indicates that this is a library playlist, meaning one of the top level library views (e.g. Music, AudioBooks, etc.).- Returns:
- true or false
- See Also:
isMaster()
-
getGeniusTrackID
int getGeniusTrackID()
-
setGeniusTrackID
void setGeniusTrackID(int geniusTrackID)
-
isGeniusPlaylist
boolean isGeniusPlaylist()
-
isAllItems
boolean isAllItems()
-
setAllItems
void setAllItems(boolean allItems)
-
getSmartInfo
String getSmartInfo()
-
setSmartInfo
void setSmartInfo(String smartInfo)
-
isSmartPlaylist
boolean isSmartPlaylist()
-
getSmartCriteria
String getSmartCriteria()
-
setSmartCriteria
void setSmartCriteria(String smartCriteria)
-
isVideos
@Deprecated boolean isVideos()
Deprecated.iTunes 6 playlist attribute.- Returns:
- true or false
-
setVideos
@Deprecated void setVideos(boolean videos)
Deprecated.
-
getFilteredSongIds
List<Long> getFilteredSongIds()
Returns song ids from this playlist, both sorted and filtered.- Returns:
- song ids
-
getSongIds
List<Long> getSongIds()
Returns song ids from this playlist, neither sorted not filtered.- Returns:
- song ids
-
getIndexedSongIds
IndexedId[] getIndexedSongIds()
A complete list of sorted ids along with their natural order indices (viaIndexedId.getIndex()). Natural indices of filtered out objects are flipped:-(index+1)- Returns:
- a complete list of persistent ids along with their natural indices
-
getSongIds
List<Long> getSongIds(Set<? extends SongFilter> filters)
Returns song ids from this playlist, filtered with the given filters.- Returns:
- song ids
- See Also:
getSongs(Collection, int)
-
getSongs
Iterable<AudioSong> getSongs()
Returns songs from this playlist, neither sorted nor filtered.- Returns:
- songs
-
getSongsOrderedBy
default Iterable<AudioSong> getSongsOrderedBy(String sortProperty)
Returns anIterablethat can be used to iterate over all songs.- 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 songs from this playlist, sorted by the given property.- Parameters:
sortProperty- propertydirection- direction- Returns:
- songs
-
getSongsOrderedBy
Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Returns songs from this playlist, sorted by the given property.- Parameters:
sortProperty- propertydirection- directionlimit- max number of songs to return- Returns:
- songs
-
getSongs
List<AudioSong> getSongs(Collection<? extends SongFilter> filters, int limit)
Returns songs from this playlist, filtered with the given filters.- Parameters:
filters- filterslimit- limit, -1 for no limit- Returns:
- songs
- See Also:
getSongIds(Set)
-
getFilteredSongs
Iterable<AudioSong> getFilteredSongs()
Returns songs from this playlist, both sorted and filtered.- Returns:
- songs
-
filteredListIterator
PlayListIterator<AudioSong> filteredListIterator(int startIndex)
Creates a dynamically updated iterator for this playlist. This iterator will adjust to sort/filter changes to the underlying playlist.
The iterator does not support mutable operations.- Parameters:
startIndex- index to start iterating from, first call toListIterator.next()orListIterator.previous()will produce the song at the given index- Returns:
- read-only, dynamically adjusting list iterator
-
countSongs
int countSongs(Collection<? extends SongFilter> filters)
Returns song count from this playlist, filtered with the given filters.- Returns:
- song count
- See Also:
getSongIds(Set)
-
setSongs
void setSongs(List<AudioSong> songs)
Removes all songs from this playlist and replaces them with the given songs. If the songs are not in your library yet, corresponding entries in the database are created.- Parameters:
songs- songs
-
setSongIds
void setSongIds(List<Long> songIds)
Removes all songs from this playlist and replaces them with song connected to the given ids.- Parameters:
songIds- song ids
-
addSongIds
void addSongIds(List<Long> songIds)
Adds the songs referenced by the given ids to this playlist.- Parameters:
songIds- song ids
-
addSongs
void addSongs(int filteredIndex, String... locations)Adds songs to the playlist using only their locations.
Depending on the library implementation, the insert index may be ignored. If it is ignored, the songs will be appended at the end (this is the case for iTunes libraries).- Parameters:
filteredIndex- filtered index, set this to-1, if you just want to add the song to the endlocations- file or URL- See Also:
AudioSongLocation.getLocation()
-
addSongs
void addSongs(int filteredIndex, List<AudioSong> songs)Adds the given songs at the given (filtered) index.- Parameters:
filteredIndex- filtered indexsongs- songs
-
addSongIds
void addSongIds(int filteredIndex, List<Long> songIds)Adds the given songs at the given (filtered) index.- Parameters:
filteredIndex- filtered indexsongIds- songs
-
moveSongs
int moveSongs(int[] fromIndices, int toIndex)Moves songs. All indices have to be filtered.- Parameters:
fromIndices- indices to move songs fromtoIndex- index to move the songs to- Returns:
- new lead index of the moved songs
-
getUnfilteredSize
int getUnfilteredSize()
Unfiltered number of songs in playlist. May return-1, if the number is unknown- Returns:
- number of songs in playlist
- See Also:
setSubstringFilter(String, PlayList.SubstringFilterProperty)
-
unfilteredIndices
int[] unfilteredIndices(int... filteredIndices)
Returns the unfiltered indices for the given filtered (string, order) indices.- Parameters:
filteredIndices- filtered indices- Returns:
- unfiltered equivalents
-
filteredIndices
int[] filteredIndices(int... unfilteredIndices)
Returns the filtered indices (string, order) for the given unfiltered indices.- Parameters:
unfilteredIndices- unfiltered indices- Returns:
- filtered equivalents or
-1, if that does not exist, because the index was filtered out
-
indexOf
int indexOf(Long id)
Returns the first index of the given song.- Parameters:
id- song id- Returns:
- index or
-1, if not found
-
indexOf
default int indexOf(AudioSong song)
Returns the first index of the given song.- Parameters:
song- song- Returns:
- index or
-1, if not found
-
removeSongs
boolean removeSongs(int... filteredIndex)
Removes the song with the given (filtered) index from the playlist. If this is a library, the file is also deleted.- Parameters:
filteredIndex- filtered indices- Returns:
- true, if the system was able to find and remove the given song
-
removeSongs
default boolean removeSongs(Collection<Long> ids)
Removes the songs with the given ids from the list. If this is the library, the songs are also deleted.- Parameters:
ids- ids- Returns:
- success
-
removeSongs
boolean removeSongs(Collection<Long> ids, boolean completelyDeleteSong)
Removes the songs with the given ids from the list.- Parameters:
completelyDeleteSong- if set totrue, the song object itself is deleted and removed from all other lists as wellids- ids- Returns:
- success
-
removeAllSongs
void removeAllSongs()
Removes all songs from this playlist.
-
getSong
AudioSong getSong(int index)
Returns song from the given index, taking sorting and filtering into account. This method may returnnulleven if a corresponding song exists, because it is loaded asynchronously.
UsegetIdAt(int), if you need a synchronous result.- Parameters:
index- index- Returns:
- song or
null, if not in the cache or the index is bad - See Also:
getIdAt(int)
-
getIdAt
Long getIdAt(int index)
Returns id of the song at the given index, taking sorting and filtering into account. Other thangetSong(int), this method always returns an id, if the index is valid.- Parameters:
index- index- Returns:
- id or null, if the index it not valid
- See Also:
getSong(int)
-
contains
boolean contains(Long id)
-
contains
default boolean contains(AudioSong song)
-
isFolder
boolean isFolder()
-
isParentAFolder
boolean isParentAFolder()
-
setFolder
void setFolder(boolean folder)
-
isUserPlaylist
boolean isUserPlaylist()
Indicates that the playlist is just a regular user playlist. Note that Matchlists are not considered regular user playlists.- Returns:
- true or false.
-
isPurchasedMusic
boolean isPurchasedMusic()
-
setPurchasedMusic
void setPurchasedMusic(boolean purchasedMusic)
-
isItemsEditable
boolean isItemsEditable()
Are the contained items editable? E.g., items are not editable, if they are only available online, as the metadata of some stream or online database cannot be changed locally.- Returns:
- true or false
-
canInsertItem
boolean canInsertItem()
Indicates whether we can insert items into this playlist.- Returns:
- true or false, typically false for generated lists like "Music"
-
canAddItem
boolean canAddItem()
Indicates whether we can add items to this playlist.- Returns:
- true or false, typically false for generated lists like "Music"
-
isEditable
boolean isEditable()
Is this playlist editable? Only playlists created by users are editable.- Returns:
- true or false
-
getTotalTime
long getTotalTime()
Get time with filters applied.- Returns:
- time
-
getUnfilteredTime
long getUnfilteredTime()
Get time without any filters applied.- Returns:
- time
-
getFileSize
long getFileSize()
Get the sum of all file sizes (with filters applied).- Returns:
- sum of file sizes
-
isAggregateDataAvailable
boolean isAggregateDataAvailable()
Indicates whether we currently have valid aggregate (total size, duration, etc.) data. If the data is not available, the asynchronous computation is triggered.- Returns:
- true or false
-
getSortColumnProperty
String getSortColumnProperty()
Returns the name of the single property the playlist is sorted by. Note that for special properties likenamethis may not be the same properties as the ones we use forORDER BYSQL clauses. But, it's the property that should be highlighted in a UI.- Returns:
- column
-
setSortColumnProperty
void setSortColumnProperty(String property)
Sets "visual/semantic" sort property.- Parameters:
property- name of the property that is marked as sorted-by in the UI- See Also:
getSortColumnProperty()
-
getSortProperty
String getSortProperty(int index)
Actual sort property, used inORDER BYSQL clauses.- Parameters:
index- index- Returns:
- property or
null
-
getSortProperties
String[] getSortProperties()
Actual sort properties, used inORDER BYHQL/SQL clauses.- Returns:
- sort properties
-
getSyncTempo
com.tagtraum.audiokern.bpm.Tempo getSyncTempo()
When set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Returns:
- sync tempo
- See Also:
setSortProperties(String...)
-
setSyncTempo
void setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
When set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
setSyncTempoin interfaceSyncTempoAware- Parameters:
syncTempo- sync tempo
-
setSortProperties
void setSortProperties(String... properties)
Sets sort properties.- Parameters:
properties- sort properties
-
setSortDirection
void setSortDirection(PlayList.SortDirection sortDirection)
Sort direction.- Parameters:
sortDirection- sort direction
-
getSortDirection
PlayList.SortDirection getSortDirection()
Return sort direction.- Returns:
- sort direction
-
getSubstringFilter
String getSubstringFilter()
Current substring filter.- Returns:
- filter string
-
setSubstringFilter
void setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Sets the filter and which property to filter in one swoop.- Parameters:
substring- filter stringsubstringFilterProperty- property to filter
-
getSubstringFilterProperty
PlayList.SubstringFilterProperty getSubstringFilterProperty()
Current property to filter.- Returns:
- which property to filter (substring)
- See Also:
setSubstringFilter(String, SubstringFilterProperty)
-
-