I have created a widget that is an extension of SurfaceView (very
similar to VideoView -
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/widget/VideoView.java;hb=HEAD)
and I am working on a feature to stretch the video fully across the
device screen when certain action is taken. I've looked at onMeasure
function of VideoView and re-wrote it this way:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (mStretchVideo) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} else {
int width = getDefaultSize(mVideoWidth, widthMeasureSpec);
int height = getDefaultSize(mVideoHeight, heightMeasureSpec);
if (mVideoWidth > 0 && mVideoHeight > 0) {
if (mVideoWidth * height > width * mVideoHeight) {
height = width * mVideoHeight / mVideoWidth;
} else if (mVideoWidth * height < width * mVideoHeight) {
width = height * mVideoWidth / mVideoHeight;
}
}
setMeasuredDimension(width, height);
}
}
This seems to work fine if I completely stop the video and start
playing again. Now I am trying to force the refresh of this
SurfaceView after setting the stretch flag so that the video gets
stretched while it is playing, but I couldn't figure out how to force
a refresh on SurfaceView. I tried android.view.View.invalidate(),
android.view.View.refreshDrawableState() and calling
android.view.View.measure(int, int) directly with different
combinations but did not get any success.
Any ideas?
Thanks.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en