Skip to content

Commit

Permalink
Fix first item played in playlists when switching player type or reso…
Browse files Browse the repository at this point in the history
…lution

The issue was caused by an ExoPlayer change, which when setting a media source, resets the current playback position and the current window index by default.

Also set player recovery in more places to fix playback position not propely set in some cases after a player type switch.
  • Loading branch information
AudricV committed Jan 24, 2022
1 parent 1531a51 commit 73cc4cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ public void onPause() {
public void onResume() {
super.onResume();

if (isPlayerAvailable()) {
// FIXME Workaround #7427
player.setRecovery();
}

activity.sendBroadcast(new Intent(ACTION_VIDEO_FRAGMENT_RESUMED));

setupBrightness();
Expand All @@ -351,6 +356,11 @@ public void onResume() {
public void onStop() {
super.onStop();

if (isPlayerAvailable()) {
// FIXME Workaround #7427
player.setRecovery();
}

if (!activity.isChangingConfigurations()) {
activity.sendBroadcast(new Intent(ACTION_VIDEO_FRAGMENT_STOPPED));
}
Expand Down Expand Up @@ -506,6 +516,12 @@ public void onClick(final View v) {
toggleTitleAndSecondaryControls();
break;
case R.id.overlay_thumbnail:
if (isPlayerAvailable()) {
// FIXME Workaround #7427
player.setRecovery();
}
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
break;
case R.id.overlay_metadata_layout:
case R.id.overlay_buttons_layout:
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ public void onPlaybackUnblock(final MediaSource mediaSource) {
if (currentState == STATE_BLOCKED) {
changeState(STATE_BUFFERING);
}
simpleExoPlayer.setMediaSource(mediaSource);
simpleExoPlayer.setMediaSource(mediaSource, false);
simpleExoPlayer.prepare();
}

Expand Down

0 comments on commit 73cc4cd

Please sign in to comment.