Use new subsonic api getRandomSongs call.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-09-16 20:57:52 +02:00
parent 0abc71cf9f
commit d848fa2669
1 changed files with 13 additions and 23 deletions

View File

@ -69,6 +69,7 @@ import org.moire.ultrasonic.api.subsonic.response.GetMusicDirectoryResponse;
import org.moire.ultrasonic.api.subsonic.response.GetPlaylistResponse; import org.moire.ultrasonic.api.subsonic.response.GetPlaylistResponse;
import org.moire.ultrasonic.api.subsonic.response.GetPlaylistsResponse; import org.moire.ultrasonic.api.subsonic.response.GetPlaylistsResponse;
import org.moire.ultrasonic.api.subsonic.response.GetPodcastsResponse; import org.moire.ultrasonic.api.subsonic.response.GetPodcastsResponse;
import org.moire.ultrasonic.api.subsonic.response.GetRandomSongsResponse;
import org.moire.ultrasonic.api.subsonic.response.LicenseResponse; import org.moire.ultrasonic.api.subsonic.response.LicenseResponse;
import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse; import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse;
import org.moire.ultrasonic.api.subsonic.response.SearchResponse; import org.moire.ultrasonic.api.subsonic.response.SearchResponse;
@ -700,28 +701,17 @@ public class RESTMusicService implements MusicService
} }
@Override @Override
public MusicDirectory getRandomSongs(int size, Context context, ProgressListener progressListener) throws Exception public MusicDirectory getRandomSongs(int size,
{ Context context,
checkServerVersion(context, "1.2", "Random songs not supported."); ProgressListener progressListener) throws Exception {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetRandomSongsResponse> response = subsonicAPIClient.getApi()
.getRandomSongs(size, null, null, null, null).execute();
checkResponseSuccessful(response);
HttpParams params = new BasicHttpParams(); MusicDirectory result = new MusicDirectory();
HttpConnectionParams.setSoTimeout(params, SOCKET_READ_TIMEOUT_GET_RANDOM_SONGS); result.addAll(APIMusicDirectoryConverter.toDomainEntityList(response.body().getSongsList()));
return result;
List<String> names = new ArrayList<String>();
List<Object> values = new ArrayList<Object>();
names.add("size");
values.add(size);
Reader reader = getReader(context, progressListener, "getRandomSongs", params, names, values);
try
{
return new RandomSongsParser(context).parse(reader, progressListener);
}
finally
{
Util.close(reader);
}
} }
@Override @Override