public interface MusicCache
An interface to efficiently retrieve music data that can be cached, usually in a database. If the cache misses,
MusicFetcher is used, and the cache is updated automatically.-
Method Summary
Modifier and TypeMethodDescriptionGets anAlbumfrom a given name and artist.getAlbumById(String id) Gets anAlbumfrom a given ID.getAlbumTracks(Album album) Gets all tracks from a givenAlbum.getArtistById(String id) Gets anArtistfrom a given ID.getArtistByName(String name) Gets anArtistfrom a given name.getIdFromString(String idOrUrl) Takes in a URL or an ID and returns the ID.getPlaylist(String name, String author) Gets aPlaylistfrom a given name and author.Gets aPlaylistfrom a given ID.getPlaylistTracks(Playlist playlist) Gets all tracks from a givenPlaylist.Gets aTrackfrom a given name and artist.getTrackById(String id) Gets aTrackfrom a given ID, specific to the service provider implementation.getTracks(List<MusicFetcher.TrackNameArtist> tracks) Gets multipleTracks from a given list ofMusicFetcher.TrackNameArtists.getTracksById(List<String> trackIds) Gets multipleTracks from a given list of IDs.
-
Method Details
-
getTrack
Gets aTrackfrom a given name and artist. If multiple tracks are found with the name/artist combination, it is up to the implementation to decide what to pick.- Parameters:
name- The name of the track, not including the artist nameartist- The name of the artist- Returns:
- The track with the given name and artist, if any
-
getTrackById
-
getTracks
Gets multipleTracks from a given list ofMusicFetcher.TrackNameArtists. This effectively performs whatgetTrack(String, String)does, but batched for multiple tracks at once.- Parameters:
tracks- The tracks to look up- Returns:
- The list of tracks that were found, in the same order as the given list of tracks. If a track isn't found, it is skipped
-
getTracksById
Gets multipleTracks from a given list of IDs. This effectively performs whatgetTrackById(String)does, but batched for multiple tracks at once. The IDs are in different formats for each service provider.- Parameters:
trackIds- The IDs of the tracks to look up- Returns:
- The list of tracks that were found, in the same order as the given list of track IDs. If a track isn't found, it is skipped.
-
getPlaylist
Gets aPlaylistfrom a given name and author. If multiple playlists are found with the name/author combination, it is up to the implementation to decide what to pick. If multiple playlists are found with the same name, it is up to the implementation to decide what to pick.- Parameters:
name- The name of the playlistauthor- The name of the artist- Returns:
- The playlist with the given name and author, if any
-
getPlaylistById
Gets aPlaylistfrom a given ID. This is in different formats for each service provider implementation.- Parameters:
id- The ID of the playlist. This is in different formats for each service provider implementation- Returns:
- The playlist with the given ID, if any
-
getAlbum
Gets anAlbumfrom a given name and artist. If multiple albums are found with the name/artist combination, it is up to the implementation to decide what to pick. If multiple albums are found with the same name, it is up to the implementation to decide what to pick.- Parameters:
name- The name of the album, not including the artist nameartist- The name of the artist- Returns:
- The album with the given name and artist, if any
-
getAlbumById
-
getAlbumTracks
-
getPlaylistTracks
-
getArtistById
Gets anArtistfrom a given ID. This is in different formats for each service provider implementation.- Parameters:
id- The ID of the artist. This is in different formats for each service provider implementation.- Returns:
- The artist with the given ID, if any
-
getArtistByName
-
getIdFromString
-