Implementation of the display of song lyrics where present

This commit is contained in:
CappielloAntonio 2021-12-19 16:48:43 +01:00
parent 12ce97836d
commit 40cbf289af
8 changed files with 148 additions and 14 deletions

View file

@ -264,4 +264,27 @@ public class SongRepository {
return song;
}
public MutableLiveData<String> getSongLyrics(Song song) {
MutableLiveData<String> lyrics = new MutableLiveData<>(null);
App.getSubsonicClientInstance(application, false)
.getMediaRetrievalClient()
.getLyrics(song.getArtistName(), song.getTitle())
.enqueue(new Callback<SubsonicResponse>() {
@Override
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
if (response.isSuccessful() && response.body() != null && response.body().getLyrics() != null) {
lyrics.setValue(response.body().getLyrics().getContent());
}
}
@Override
public void onFailure(@NonNull Call<SubsonicResponse> call, @NonNull Throwable t) {
}
});
return lyrics;
}
}