From 47d8b7ff164ae2b162913ec9fea92bcc7fa58839 Mon Sep 17 00:00:00 2001 From: Drew Hill Date: Sun, 18 Dec 2016 22:37:37 -0500 Subject: [PATCH] get source dimensions from plane stored in subs --- .../android/exoplayer2/text/ImageCue.java | 22 +++++++++++++------ .../exoplayer2/ui/SimpleExoPlayerView.java | 12 ++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/text/ImageCue.java b/library/src/main/java/com/google/android/exoplayer2/text/ImageCue.java index 2dc0c97238..b5906cf41d 100644 --- a/library/src/main/java/com/google/android/exoplayer2/text/ImageCue.java +++ b/library/src/main/java/com/google/android/exoplayer2/text/ImageCue.java @@ -7,19 +7,25 @@ public class ImageCue extends Cue { final private long start_display_time; final private int x; final private int y; - final private int height; - final private int width; + final private int bitmap_height; + final private int bitmap_width; + final private int plane_height; + final private int plane_width; final private Bitmap bitmap; final private boolean isForced; - public ImageCue(Bitmap bitmap, long start_display_time, int x, int y, int width, int height, boolean isForced) { + public ImageCue(Bitmap bitmap, long start_display_time, + int x, int y, int bitmap_width, int bitmap_height, boolean isForced, + int plane_width, int plane_height) { super(""); this.bitmap = bitmap; this.start_display_time = start_display_time; this.x = x; this.y = y; - this.width = width; - this.height = height; + this.bitmap_width = bitmap_width; + this.bitmap_height = bitmap_height; + this.plane_width = plane_width; + this.plane_height = plane_height; this.isForced = isForced; } @@ -27,7 +33,9 @@ public class ImageCue extends Cue { public Bitmap getBitmap() { return bitmap; } public int getX() { return x; } public int getY() { return y; } - public int getWidth() { return width; } - public int getHeight() { return height; } + public int getBitmapWidth() { return bitmap_width; } + public int getBitmapHeight() { return bitmap_height; } + public int getPlaneWidth() { return plane_width; } + public int getPlaneHeight() { return plane_height; } public boolean isForcedSubtitle() { return isForced; } } diff --git a/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java b/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java index e01956c803..ffe2ca31e0 100644 --- a/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java +++ b/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java @@ -614,10 +614,6 @@ public final class SimpleExoPlayerView extends FrameLayout { private final class ComponentListener implements SimpleExoPlayer.VideoListener, TextRenderer.Output, ExoPlayer.EventListener { - - private int sourceWidth = 0; - private int sourceHeight = 0; - // TextRenderer.Output implementation @Override @@ -648,10 +644,12 @@ public final class SimpleExoPlayerView extends FrameLayout { int surfaceAnchorY = (int) surfaceView.getY(); int surfaceWidth = surfaceView.getWidth(); int surfaceHeight = surfaceView.getHeight(); + int sourceWidth = cue.getPlaneWidth(); + int sourceHeight = cue.getPlaneHeight(); int subAnchorX = cue.getX(); int subAnchorY = cue.getY(); - int subScaleWidth = cue.getWidth(); - int subScaleHeight = cue.getHeight(); + int subScaleWidth = cue.getBitmapWidth(); + int subScaleHeight = cue.getBitmapHeight(); // they should change together as we keep the aspect ratio if ((surfaceHeight != sourceHeight || surfaceWidth != sourceWidth) @@ -691,8 +689,6 @@ public final class SimpleExoPlayerView extends FrameLayout { public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { - sourceWidth = width; - sourceHeight = height; if (contentFrame != null) { float aspectRatio = height == 0 ? 1 : (width * pixelWidthHeightRatio) / height; contentFrame.setAspectRatio(aspectRatio);