mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-01-09 08:29:04 +00:00
Merge pull request #12952 from TeamNewPipe/fix/NaN-on-minimize
fix(player): Fix scaleX being NaN on minimize to background app switch
This commit is contained in:
@@ -1554,6 +1554,11 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
|
||||
@Override
|
||||
public void onVideoSizeChanged(@NonNull final VideoSize videoSize) {
|
||||
super.onVideoSizeChanged(videoSize);
|
||||
// Starting with ExoPlayer 2.19.0, the VideoSize will report a width and height of 0
|
||||
// if the renderer is disabled. In that case, we skip updating the aspect ratio.
|
||||
if (videoSize.width == 0 || videoSize.height == 0) {
|
||||
return;
|
||||
}
|
||||
binding.surfaceView.setAspectRatio(((float) videoSize.width) / videoSize.height);
|
||||
}
|
||||
//endregion
|
||||
|
||||
@@ -35,12 +35,12 @@ public class ExpandableSurfaceView extends SurfaceView {
|
||||
&& resizeMode != RESIZE_MODE_FIT
|
||||
&& verticalVideo ? maxHeight : baseHeight;
|
||||
|
||||
if (height == 0) {
|
||||
if (width == 0 || height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float viewAspectRatio = width / ((float) height);
|
||||
final float aspectDeformation = videoAspectRatio / viewAspectRatio - 1;
|
||||
final float aspectDeformation = (videoAspectRatio / viewAspectRatio) - 1;
|
||||
scaleX = 1.0f;
|
||||
scaleY = 1.0f;
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ExpandableSurfaceView extends SurfaceView {
|
||||
}
|
||||
|
||||
public void setAspectRatio(final float aspectRatio) {
|
||||
if (videoAspectRatio == aspectRatio) {
|
||||
if (videoAspectRatio == aspectRatio || aspectRatio == 0 || !Float.isFinite(aspectRatio)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user