1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Use player.getThumbnail() instead of field in VideoPlayerUi

This commit is contained in:
Stypox 2022-08-28 18:35:21 +02:00
parent 4a7af6f9ac
commit f9109ebc81
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -109,7 +109,6 @@ public abstract class VideoPlayerUi extends PlayerUi
private final Handler controlsVisibilityHandler = new Handler(Looper.getMainLooper()); private final Handler controlsVisibilityHandler = new Handler(Looper.getMainLooper());
@Nullable private SurfaceHolderCallback surfaceHolderCallback; @Nullable private SurfaceHolderCallback surfaceHolderCallback;
boolean surfaceIsSetup = false; boolean surfaceIsSetup = false;
@Nullable private Bitmap thumbnail = null;
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -385,9 +384,7 @@ public abstract class VideoPlayerUi extends PlayerUi
@Override @Override
public void destroy() { public void destroy() {
super.destroy(); super.destroy();
if (binding != null) { binding.endScreen.setImageDrawable(null);
binding.endScreen.setImageBitmap(null);
}
deinitPlayerSeekOverlay(); deinitPlayerSeekOverlay();
deinitListeners(); deinitListeners();
} }
@ -422,12 +419,10 @@ public abstract class VideoPlayerUi extends PlayerUi
public void onBroadcastReceived(final Intent intent) { public void onBroadcastReceived(final Intent intent) {
super.onBroadcastReceived(intent); super.onBroadcastReceived(intent);
if (Intent.ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) { if (Intent.ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) {
// When the orientation changed, the screen height might be smaller. // When the orientation changes, the screen height might be smaller. If the end screen
// If the end screen thumbnail is not re-scaled, // thumbnail is not re-scaled, it can be larger than the current screen height and thus
// it can be larger than the current screen height // enlarging the whole player. This causes the seekbar to be out of the visible area.
// and thus enlarging the whole player. updateEndScreenThumbnail(player.getThumbnail());
// This causes the seekbar to be ouf the visible area.
updateEndScreenThumbnail();
} }
} }
//endregion //endregion
@ -449,11 +444,10 @@ public abstract class VideoPlayerUi extends PlayerUi
@Override @Override
public void onThumbnailLoaded(@Nullable final Bitmap bitmap) { public void onThumbnailLoaded(@Nullable final Bitmap bitmap) {
super.onThumbnailLoaded(bitmap); super.onThumbnailLoaded(bitmap);
thumbnail = bitmap; updateEndScreenThumbnail(bitmap);
updateEndScreenThumbnail();
} }
private void updateEndScreenThumbnail() { private void updateEndScreenThumbnail(@Nullable final Bitmap thumbnail) {
if (thumbnail == null) { if (thumbnail == null) {
// remove end screen thumbnail // remove end screen thumbnail
binding.endScreen.setImageDrawable(null); binding.endScreen.setImageDrawable(null);