minor changes to playback interface

This commit is contained in:
dkanada 2020-10-18 23:51:04 +09:00
commit 69e636e446
3 changed files with 22 additions and 20 deletions

View file

@ -21,12 +21,12 @@ public class EventListener extends ApiEventListener {
@Override
public void onRemoteLoggedOut(ApiClient client, RemoteLogoutReason reason) {
Log.i(TAG, "onRemoteLoggedOut");
Log.i(TAG, "onRemoteLoggedOut: " + reason);
}
@Override
public void onUserUpdated(ApiClient client, UserDto userDto) {
Log.i(TAG, "onUserUpdated");
Log.i(TAG, "onUserUpdated: " + userDto.getName());
}
@Override
@ -41,12 +41,12 @@ public class EventListener extends ApiEventListener {
@Override
public void onBrowseCommand(ApiClient client, BrowseRequest command) {
Log.i(TAG, "onBrowseCommand");
Log.i(TAG, "onBrowseCommand: " + command.getItemName());
}
@Override
public void onPlayCommand(ApiClient client, PlayRequest command) {
Log.i(TAG, "onPlayCommand");
Log.i(TAG, "onPlayCommand: " + command.getPlayCommand());
}
@Override
@ -92,7 +92,7 @@ public class EventListener extends ApiEventListener {
@Override
public void onGeneralCommand(ApiClient client, GeneralCommand command) {
Log.i(TAG, "onGeneralCommand");
Log.i(TAG, "onGeneralCommand: " + command.getName());
}
@Override

View file

@ -5,6 +5,8 @@ import android.net.Uri;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.dkanada.gramophone.App;
import com.dkanada.gramophone.R;
import com.dkanada.gramophone.model.Song;
@ -60,9 +62,9 @@ public class MultiPlayer implements Playback {
private boolean requestPlay = false;
private int requestProgress = 0;
private ExoPlayer.EventListener eventListener = new ExoPlayer.EventListener() {
private final ExoPlayer.EventListener eventListener = new ExoPlayer.EventListener() {
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
public void onTracksChanged(@NonNull TrackGroupArray trackGroups, @NonNull TrackSelectionArray trackSelections) {
Log.i(TAG, "onTracksChanged");
}
@ -226,6 +228,11 @@ public class MultiPlayer implements Playback {
return isReady;
}
@Override
public boolean isPlaying() {
return isReady && isPlaying;
}
@Override
public void start() {
if (!isReady) {
@ -251,11 +258,6 @@ public class MultiPlayer implements Playback {
isReady = false;
}
@Override
public boolean isPlaying() {
return isReady && isPlaying;
}
@Override
public int getProgress() {
if (!isReady) return -1;
@ -269,13 +271,13 @@ public class MultiPlayer implements Playback {
}
@Override
public void setProgress(int position) {
public void setProgress(int progress) {
if (!isReady) {
requestProgress = position;
requestProgress = progress;
return;
}
exoPlayer.seekTo(position);
exoPlayer.seekTo(progress);
}
@Override

View file

@ -9,21 +9,21 @@ public interface Playback {
void setCallbacks(PlaybackCallbacks callbacks);
boolean isReady();
boolean isPlaying();
void start();
void pause();
void stop();
boolean isReady();
boolean isPlaying();
int getProgress();
int getDuration();
void setProgress(int position);
void setProgress(int progress);
void setVolume(int volume);