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 ofAudioSong
s.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
PlayList.Kind
Kinds of playlists.static class
PlayList.SortDirection
Sort direction.static class
PlayList.SubstringFilterProperty
Properties 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 void
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Add a listener.void
addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Add a listener for a specific property.void
addSongIds(int filteredIndex, List<Long> songIds)
Adds the given songs at the given (filtered) index.void
addSongIds(List<Long> songIds)
Adds the songs referenced by the given ids to this playlist.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.void
addSongs(int filteredIndex, List<AudioSong> songs)
Adds the given songs at the given (filtered) index.boolean
canAddItem()
Indicates whether we can add items to this playlist.boolean
canInsertItem()
Indicates whether we can insert items into this playlist.default boolean
contains(AudioSong song)
boolean
contains(Long id)
int
countSongs(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()
String
getDescription()
PlayList.Kind
getDistinguishedKind()
Returns the special kind of this playlist.long
getFileSize()
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.int
getGeniusTrackID()
Long
getId()
This list's id.Long
getIdAt(int index)
Returns id of the song at the given index, taking sorting and filtering into account.<T> T
getImplementation(Class<T> klass)
PlayList
objects 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.Liking
getLiking()
String
getName()
Long
getParentId()
If this is a sub-folder/playlist, this returns the parent id.PlayList
getParentPlayList()
PlayList[]
getPlayListPath()
Returns path leading to this playlist and ending with it.String
getSmartCriteria()
String
getSmartInfo()
AudioSong
getSong(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 anIterable
that 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.String
getSortColumnProperty()
Returns the name of the single property the playlist is sorted by.PlayList.SortDirection
getSortDirection()
Return sort direction.String[]
getSortProperties()
Actual sort properties, used inORDER BY
HQL/SQL clauses.String
getSortProperty(int index)
Actual sort property, used inORDER BY
SQL clauses.SpecialPlayListInfo
getSpecialPlayListInfo()
Long
getSpecialPlayListInfoId()
String
getSubstringFilter()
Current substring filter.PlayList.SubstringFilterProperty
getSubstringFilterProperty()
Current property to filter.com.tagtraum.audiokern.bpm.Tempo
getSyncTempo()
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo.long
getTotalTime()
Get time with filters applied.int
getUnfilteredSize()
Unfiltered number of songs in playlist.long
getUnfilteredTime()
Get time without any filters applied.default int
indexOf(AudioSong song)
Returns the first index of the given song.int
indexOf(Long id)
Returns the first index of the given song.boolean
isAggregateDataAvailable()
Indicates whether we currently have valid aggregate (total size, duration, etc.) data.boolean
isAllItems()
boolean
isAudiobooks()
boolean
isEditable()
Is this playlist editable? Only playlists created by users are editable.boolean
isFolder()
boolean
isGeniusPlaylist()
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.boolean
isLibrary()
Indicates that this is a library playlist, meaning one of the top level library views (e.g.boolean
isMaster()
Indicates whether this playlist is a master playlist.boolean
isMovies()
boolean
isMusic()
boolean
isParentAFolder()
boolean
isPodcasts()
boolean
isPurchasedMusic()
boolean
isSmartPlaylist()
boolean
isSpecialPlayList()
boolean
isTvShows()
boolean
isUserPlaylist()
Indicates that the playlist is just a regular user playlist.boolean
isVideos()
Deprecated.int
moveSongs(int[] fromIndices, int toIndex)
Moves songs.void
removeAllSongs()
Removes all songs from this playlist.void
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Remove a listener.boolean
removeSongs(int... filteredIndex)
Removes the song with the given (filtered) index from the playlist.default boolean
removeSongs(Collection<Long> ids)
Removes the songs with the given ids from the list.boolean
removeSongs(Collection<Long> ids, boolean completelyDeleteSong)
Removes the songs with the given ids from the list.void
setAllItems(boolean allItems)
void
setAudiobooks(boolean audiobooks)
void
setChildPlayLists(List<PlayList> childPlayLists)
void
setDescription(String description)
void
setDistinguishedKind(PlayList.Kind distinguishedKind)
Allows setting of a special song type, likePlayList.Kind.PODCASTS
.void
setFolder(boolean folder)
void
setGeniusTrackID(int geniusTrackID)
void
setId(Long id)
Sets this list's id.void
setLiking(AudioSong.Liking liking)
void
setMaster(boolean master)
void
setMovies(boolean movies)
void
setMusic(boolean music)
void
setName(String name)
void
setParentId(Long parentId)
Sets the parent id.void
setParentPlayList(PlayList parentPlayList)
void
setPodcasts(boolean podcasts)
void
setPurchasedMusic(boolean purchasedMusic)
void
setSmartCriteria(String smartCriteria)
void
setSmartInfo(String smartInfo)
void
setSongIds(List<Long> songIds)
Removes all songs from this playlist and replaces them with song connected to the given ids.void
setSongs(List<AudioSong> songs)
Removes all songs from this playlist and replaces them with the given songs.void
setSortColumnProperty(String property)
Sets "visual/semantic" sort property.void
setSortDirection(PlayList.SortDirection sortDirection)
Sort direction.void
setSortProperties(String... properties)
Sets sort properties.void
setSpecialPlayListInfo(SpecialPlayListInfo specialPlayListInfo)
void
setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Sets the filter and which property to filter in one swoop.void
setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo.void
setTvShows(boolean tvShows)
void
setVideos(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)
PlayList
objects 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:
null
if 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 anIterable
that 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 returnnull
even 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 likename
this may not be the same properties as the ones we use forORDER BY
SQL 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 BY
SQL clauses.- Parameters:
index
- index- Returns:
- property or
null
-
getSortProperties
String[] getSortProperties()
Actual sort properties, used inORDER BY
HQL/SQL clauses.- Returns:
- sort properties
-
getSyncTempo
com.tagtraum.audiokern.bpm.Tempo getSyncTempo()
When set to a non-null
value,Key
values 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-null
value,Key
values are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
setSyncTempo
in 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)
-
-