I have similar code to many examples floating around the net:
mSurfaceHolder = mVideoSurface.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
mSurfaceHolder.setFixedSize(20, 10);
Then in the callbacks I have:
@Override public void surfaceCreated(SurfaceHolder holder)
{
Log.d(TAG, "SurfaceCreated");
mSurfaceHolder.setFixedSize(20, 10);
}
@Override public void surfaceChanged(
SurfaceHolder holder, int format, int width, int height
)
{
Log.d(TAG, "SurfaceChanged to " +
format + " width " + width + " height " + height);
}
From this code I would expect the video surface to be set to the tiny size of 20x10 pixels, then scaled back up to whatever layout size I'm using it, showing a pixelated/blurred version. However, the video being played back looks right in its full native resolution, it doesn't scale down to 20x10. But I get logs like these:
SurfaceChanged to -2 width 20 height 10
So if the video surface is set to this tiny size, but graphically the video still looks high definition, what is the use of setting the surface size?
Full source code available at https://github.com/gradha/Stackoverflow38118219.