mr.icetea mr.icetea - 1 month ago 23
Android Question

Exoplayer video does not scale when SurfaceView is scaled

I'm using Exoplayer library to create video player application. I'm trying to make a feature like youtube: drag video player to bottom and i will be scaled to smaller size. To do that, i have used ViewDragHelper. When player is dragging, i scale it size like this:

public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
mTop = top;

mDragOffset = (float) top / mDragRange;

mVideoView.setPivotX(mHeaderView.getWidth());
mVideoView.setPivotY(mHeaderView.getHeight());
mVideoView.setScaleX(1 - mDragOffset / 2);
mVideoView.setScaleY(1 - mDragOffset / 2);

mDescView.setAlpha(1 - mDragOffset);
requestLayout();
}


mVideoView
is a
SurfaceView
, and player take
SurfaceView
to render it content. The
SurfaceView
scale correctly but it's content doesn't.

Question: how can scale SurfaceView and it's content too?

Answer

Finally, i have found a solution for my question. I used TextureView instead SurfaceView, now it worked perfect.