Fix voice note playback for single voice notes.
This commit is contained in:
parent
24cd11152b
commit
d35d22c7d8
1 changed files with 6 additions and 1 deletions
|
@ -111,6 +111,7 @@ public class VoiceNotePlaybackService extends MediaSessionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class VoiceNotePlayerEventListener implements Player.Listener {
|
private class VoiceNotePlayerEventListener implements Player.Listener {
|
||||||
|
private int previousPlaybackState = player.getPlaybackState();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
|
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
|
||||||
|
@ -123,6 +124,7 @@ public class VoiceNotePlaybackService extends MediaSessionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPlaybackStateChanged(boolean playWhenReady, int playbackState) {
|
private void onPlaybackStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
|
Log.d(TAG, "playWhenReady: " + playWhenReady + "\nplaybackState: " + playbackState);
|
||||||
switch (playbackState) {
|
switch (playbackState) {
|
||||||
case Player.STATE_BUFFERING:
|
case Player.STATE_BUFFERING:
|
||||||
case Player.STATE_READY:
|
case Player.STATE_READY:
|
||||||
|
@ -134,10 +136,13 @@ public class VoiceNotePlaybackService extends MediaSessionService {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Player.STATE_ENDED:
|
case Player.STATE_ENDED:
|
||||||
|
if (previousPlaybackState == Player.STATE_READY) {
|
||||||
player.clearMediaItems();
|
player.clearMediaItems();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
previousPlaybackState = playbackState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue