public class SubsonicConnection extends java.lang.Object implements Connection
Constructor and Description |
---|
SubsonicConnection(java.net.URL urlObj,
java.lang.String user,
java.lang.String pass)
Constructs a SubsonicConnection to the specified server URL using the provided username and password.
|
SubsonicConnection(java.net.URL urlObj,
java.lang.String user,
java.lang.String pass,
boolean isPassEncoded)
Constructs a SubsonicConnection to the specified server URL using the provided username and password.
|
SubsonicConnection(java.net.URL urlObj,
java.lang.String user,
java.lang.String pass,
java.lang.String clientIdentifier)
Constructs a SubsonicConnection to the specified server URL using the provided username, password and client identifier.
|
SubsonicConnection(java.net.URL urlObj,
java.lang.String user,
java.lang.String pass,
java.lang.String clientIdentifier,
boolean isPassEncoded)
Constructs a SubsonicConnection to the specified server URL using the provided username, password and client identifier.
|
Modifier and Type | Method and Description |
---|---|
SubsonicResponse |
createPlaylist(java.util.List<java.lang.String> songsList,
java.lang.String name)
Creates a new playlist with the specified songs list and name
|
SubsonicResponse |
deletePlaylist(java.lang.String playlistId)
Deletes the specified playlist
|
java.io.InputStream |
download(java.lang.String uniqueId)
Gets a stream of an element (directory or song) to be downloaded.
|
GetAlbumsResponse |
getAlbumsList(GetAlbumsType type)
Gets a list of 10 albums of the specified type
|
GetAlbumsResponse |
getAlbumsList(GetAlbumsType type,
int size)
Gets the defined number of albums of the specified type
|
GetAlbumsResponse |
getAlbumsList(GetAlbumsType type,
int size,
int offset)
Gets the defined number of albums of the specified type
|
Version |
getApiVersion()
Returns current server API version
|
java.awt.image.BufferedImage |
getCoverArt(java.lang.String coverId)
Returns a cover art specified by the provided ID and a size of 100x100 pixels
|
java.awt.image.BufferedImage |
getCoverArt(java.lang.String coverId,
int size)
Returns a cover art defined by the provided ID and a specified size
|
GetIndexesResponse |
getIndexes()
Gets a list of all the directories (indexes) in the root of all music folders
|
GetIndexesResponse |
getIndexes(long modifiedSince)
Gets a list of all the directories (indexes) in the root of all music folders that has been modified after the specified timestamp
|
GetIndexesResponse |
getIndexes(java.lang.String musicFolderId)
Gets a list of all the directories (indexes) in the root of the specified music folder
|
GetIndexesResponse |
getIndexes(java.lang.String musicFolderId,
long modifiedSince)
Gets a list of all the directories (indexes) in the root of the specified music folder that has been modified after the specified timestamp
|
GetLicenseResponse |
getLicense()
Gets detailed information about current server license
|
GetMusicDirectoryResponse |
getMusicDirectory(java.lang.String uniqueFolderId)
Returns all the albums and songs in specified directory
|
GetMusicFoldersResponse |
getMusicFolders()
Gets the available music folders list
|
GetPlaylistResponse |
getPlaylist(java.lang.String playlistId)
Gets information about a specific playlist including songs list on that playlist
|
GetPlaylistsResponse |
getPlaylists()
Gets the playlists available for the current user
|
GetPodcastResponse |
getPodcastEpisodes(java.lang.String podcastId)
Gets the episodes of the specified podcast
|
GetPodcastsResponse |
getPodcasts()
Gets the list of podcasts in the server
|
GetRandomSongsResponse |
getRandomSongs()
Gets a list of 10 random songs in all music folders
|
GetRandomSongsResponse |
getRandomSongs(java.lang.String folderId)
Gets a list of 10 random songs in a specific music folder
|
GetRandomSongsResponse |
getRandomSongs(java.lang.String folderId,
int size)
Gets a defined number of random songs in a specific music folder
|
java.lang.String |
getStreamURL(java.lang.String uniqueId)
Returns a valid URL for streaming a song from the current Subsonic server specified by its ID
|
java.lang.String |
getStreamURL(java.lang.String uniqueId,
int maxBitRate)
Returns a valid URL for streaming a song from the current Subsonic server specified by its ID
|
boolean |
ping()
Checks connectivity with current Subsonic server.
|
SearchResponse |
search(java.lang.String query)
Gets a list of max 20 artists, albums and songs that meet the specified query.
|
SearchResponse |
search(java.lang.String query,
int count)
Gets the specified number of artists, albums and songs that meet the specified query.
|
SearchResponse |
search(java.lang.String query,
int count,
int offset)
Gets the specified number of artists, albums and songs that meet the specified query.
|
SubsonicResponse |
setRating(AlbumRating rating)
Sets an album rating
|
java.io.InputStream |
stream(java.lang.String uniqueId)
Gets the stream of a song to be played.
|
java.io.InputStream |
stream(java.lang.String uniqueId,
int maxBitRate)
Gets the stream of a song to be played.
|
public SubsonicConnection(java.net.URL urlObj, java.lang.String user, java.lang.String pass) throws java.security.KeyManagementException, java.security.NoSuchAlgorithmException
urlObj
- Server URLuser
- Usernamepass
- Hex-encoded passwordjava.security.NoSuchAlgorithmException
java.security.KeyManagementException
public SubsonicConnection(java.net.URL urlObj, java.lang.String user, java.lang.String pass, boolean isPassEncoded) throws java.security.KeyManagementException, java.security.NoSuchAlgorithmException
urlObj
- Server URLuser
- Usernamepass
- Password, either hex-encoded or notisPassEncoded
- Defines if password is hex-encoded or notjava.security.NoSuchAlgorithmException
java.security.KeyManagementException
public SubsonicConnection(java.net.URL urlObj, java.lang.String user, java.lang.String pass, java.lang.String clientIdentifier) throws java.security.KeyManagementException, java.security.NoSuchAlgorithmException
urlObj
- Server URLuser
- Usernamepass
- Hex-encoded passwordclientIdentifier
- Client identifier (Identifies this application in Subsonic web interface and logs)java.security.NoSuchAlgorithmException
java.security.KeyManagementException
public SubsonicConnection(java.net.URL urlObj, java.lang.String user, java.lang.String pass, java.lang.String clientIdentifier, boolean isPassEncoded) throws java.security.KeyManagementException, java.security.NoSuchAlgorithmException
urlObj
- Server URLuser
- Usernamepass
- Password, either hex-encoded or notclientIdentifier
- Client identifier (Identifies this application in Subsonic web interface and logs)isPassEncoded
- Defines if password is hex-encoded or notjava.security.NoSuchAlgorithmException
java.security.KeyManagementException
public Version getApiVersion()
public boolean ping()
Connection
ping
in interface Connection
public GetLicenseResponse getLicense() throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getLicense
in interface Connection
GetLicenseResponse
object with the server license informationcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetMusicFoldersResponse getMusicFolders() throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getMusicFolders
in interface Connection
GetMusicFoldersResponse
object with the folders listcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetIndexesResponse getIndexes() throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getIndexes
in interface Connection
GetIndexesResponse
object with the indexes listcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetIndexesResponse getIndexes(java.lang.String musicFolderId) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getIndexes
in interface Connection
musicFolderId
- Id of the music folder to be listedGetIndexesResponse
object with the indexes listcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetIndexesResponse getIndexes(long modifiedSince) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getIndexes
in interface Connection
modifiedSince
- Timestamp in millisecondsGetIndexesResponse
object with the indexes listcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetIndexesResponse getIndexes(java.lang.String musicFolderId, long modifiedSince) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getIndexes
in interface Connection
musicFolderId
- Id of the music folder to be listedmodifiedSince
- Timestamp in millisecondsGetIndexesResponse
object with the indexes listcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetMusicDirectoryResponse getMusicDirectory(java.lang.String uniqueFolderId) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getMusicDirectory
in interface Connection
uniqueFolderId
- ID of the directory to be listedGetMusicDirectoryResponse
object with the albums and songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public SearchResponse search(java.lang.String query) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
search
in interface Connection
query
- Search criterionSearchResponse
object with the artists, albums and songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public SearchResponse search(java.lang.String query, int count) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
search
in interface Connection
query
- Search criterioncount
- Max number of artists, albums and songs to returnSearchResponse
object with the artists, albums and songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public SearchResponse search(java.lang.String query, int count, int offset) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
search
in interface Connection
query
- Search criterioncount
- Max number of artists, albums and songs to returnoffset
- Index to start returning results. For pagination purposesSearchResponse
object with the artists, albums and songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetPlaylistsResponse getPlaylists() throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getPlaylists
in interface Connection
GetPlaylistsResponse
object with the playlists availablecom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetPlaylistResponse getPlaylist(java.lang.String playlistId) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getPlaylist
in interface Connection
playlistId
- ID of the playlist to be returnedGetPlaylistResponse
object with information about the specified playlistcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public SubsonicResponse createPlaylist(java.util.List<java.lang.String> songsList, java.lang.String name) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
createPlaylist
in interface Connection
songsList
- List of IDs of songs that will form the playlistname
- Name to be asigned to the playlistSubsonicResponse
objectcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public SubsonicResponse deletePlaylist(java.lang.String playlistId) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
deletePlaylist
in interface Connection
playlistId
- ID of the playlist to be deletedSubsonicResponse
objectcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetAlbumsResponse getAlbumsList(GetAlbumsType type) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getAlbumsList
in interface Connection
type
- Type of the albums to be returned. Valid types are defined in GetAlbumsType
GetAlbumsResponse
object with the list of albumscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200GetAlbumsType
public GetAlbumsResponse getAlbumsList(GetAlbumsType type, int size) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getAlbumsList
in interface Connection
type
- Type of the albums to be returned. Valid types are defined in GetAlbumsType
size
- Number of albums to returnGetAlbumsResponse
object with the list of albumscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetAlbumsResponse getAlbumsList(GetAlbumsType type, int size, int offset) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getAlbumsList
in interface Connection
type
- Type of the albums to be returned. Valid types are defined in GetAlbumsType
size
- Number of albums to returnoffset
- Index to start returning results. For pagination purposesGetAlbumsResponse
object with the list of albumscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetRandomSongsResponse getRandomSongs() throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getRandomSongs
in interface Connection
GetRandomSongsResponse
object with the list of songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetRandomSongsResponse getRandomSongs(java.lang.String folderId) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getRandomSongs
in interface Connection
folderId
- ID of the music folder used to get the songs listGetRandomSongsResponse
object with the list of songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetRandomSongsResponse getRandomSongs(java.lang.String folderId, int size) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getRandomSongs
in interface Connection
folderId
- ID of the music folder used to get the songs listsize
- Number of songs the be returnedGetRandomSongsResponse
object with the list of songscom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetPodcastsResponse getPodcasts() throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getPodcasts
in interface Connection
GetPodcastsResponse
object with the list of channels the server is subscribedcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public GetPodcastResponse getPodcastEpisodes(java.lang.String podcastId) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
getPodcastEpisodes
in interface Connection
podcastId
- ID of the podcast channel whose episodes have to be returnedGetPodcastResponse
object with the list of episodes of the podcastcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200public SubsonicResponse setRating(AlbumRating rating) throws com.google.gson.JsonSyntaxException, java.io.IOException, SubsonicException, InvalidResponseException, CompatibilityException, javax.xml.ws.http.HTTPException
Connection
setRating
in interface Connection
rating
- AlbumRating object with the album id and the rating to be set to that albumSubsonicResponse
objectcom.google.gson.JsonSyntaxException
java.io.IOException
SubsonicException
- If a Subsonic error occursInvalidResponseException
- If the Subsonic servers returns a non parseable responseCompatibilityException
- If this method is not compatible with the current serverjavax.xml.ws.http.HTTPException
- If the server response code is other than 200AlbumRating
public java.io.InputStream download(java.lang.String uniqueId) throws javax.xml.ws.http.HTTPException, java.io.IOException, InvalidResponseException
Connection
download
in interface Connection
uniqueId
- ID of the element to be downloadedjavax.xml.ws.http.HTTPException
- If the server response code is other than 200java.io.IOException
InvalidResponseException
- If the Subsonic servers returns a non parseable responsepublic java.io.InputStream stream(java.lang.String uniqueId) throws javax.xml.ws.http.HTTPException, java.io.IOException, InvalidResponseException
Connection
stream
in interface Connection
uniqueId
- ID of the song to be playedjavax.xml.ws.http.HTTPException
- If the server response code is other than 200java.io.IOException
InvalidResponseException
- If the Subsonic servers returns a non parseable responsepublic java.io.InputStream stream(java.lang.String uniqueId, int maxBitRate) throws java.io.IOException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
stream
in interface Connection
uniqueId
- ID of the song to be playedmaxBitRate
- Max bitrate of the streamjava.io.IOException
InvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public java.lang.String getStreamURL(java.lang.String uniqueId)
Connection
getStreamURL
in interface Connection
uniqueId
- ID of the song to be playedpublic java.lang.String getStreamURL(java.lang.String uniqueId, int maxBitRate)
Connection
getStreamURL
in interface Connection
uniqueId
- ID of the song to be playedmaxBitRate
- Max bitrate of the streampublic java.awt.image.BufferedImage getCoverArt(java.lang.String coverId) throws java.io.IOException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getCoverArt
in interface Connection
coverId
- ID of the cover art to be returnedjava.io.IOException
InvalidResponseException
- If Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200public java.awt.image.BufferedImage getCoverArt(java.lang.String coverId, int size) throws java.io.IOException, InvalidResponseException, javax.xml.ws.http.HTTPException
Connection
getCoverArt
in interface Connection
coverId
- ID of the cover art to be returnedsize
- Size in pixels of the returned imagejava.io.IOException
InvalidResponseException
- If the Subsonic servers returns a non parseable responsejavax.xml.ws.http.HTTPException
- If the server response code is other than 200