mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-21 19:48:29 +00:00
Make voice note playback log statement more readable.
This commit is contained in:
@@ -115,24 +115,23 @@ public class VoiceNotePlaybackService extends MediaSessionService {
|
||||
|
||||
@Override
|
||||
public void onPlaybackStateChanged(int playbackState) {
|
||||
Log.d(TAG, "[onPlaybackStateChanged] playbackState: " + playbackState);
|
||||
boolean playWhenReady = player.getPlayWhenReady();
|
||||
Log.d(TAG, "[onPlaybackStateChanged] playbackState: " + playbackStateToString(playbackState) + "\tplayWhenReady: " + playWhenReady);
|
||||
switch (playbackState) {
|
||||
case Player.STATE_BUFFERING:
|
||||
case Player.STATE_READY:
|
||||
|
||||
case Player.STATE_BUFFERING, Player.STATE_READY -> {
|
||||
if (!playWhenReady) {
|
||||
stopForeground(false);
|
||||
} else {
|
||||
sendViewedReceiptForCurrentWindowIndex();
|
||||
}
|
||||
break;
|
||||
case Player.STATE_ENDED:
|
||||
}
|
||||
case Player.STATE_ENDED -> {
|
||||
if (previousPlaybackState == Player.STATE_READY) {
|
||||
player.clearMediaItems();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
previousPlaybackState = playbackState;
|
||||
}
|
||||
@@ -361,4 +360,14 @@ public class VoiceNotePlaybackService extends MediaSessionService {
|
||||
Log.e(TAG, "Could not start VoiceNotePlaybackService, encountered a ForegroundServiceStartNotAllowedException.");
|
||||
}
|
||||
}
|
||||
|
||||
private String playbackStateToString(int playbackState) {
|
||||
return switch (playbackState) {
|
||||
case Player.STATE_IDLE -> "Player.STATE_IDLE";
|
||||
case Player.STATE_BUFFERING -> "Player.STATE_BUFFERING";
|
||||
case Player.STATE_READY -> "Player.STATE_READY";
|
||||
case Player.STATE_ENDED -> "Player.STATE_ENDED";
|
||||
default -> "UNKNOWN(" + playbackState + ")";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user