I'm trying to animate the size and position of a video. Currently I'm using
a videoview. I am using a surfaceview to do all my drawing, and I have the
videoview underneath it. I cutout/draw transparent regions in the
surfaceview to show the video view.
This all works great if the position of the transparent region is still. I
can resize the region and videoview to full screen and that also works. But
if I want to move&resize the region&video, it doesn't respond.
Here's the code of the video view.
public class MyVideoView extends VideoView {
protected int _overrideWidth =320;
protected int _overrideHeight =240;
public CupVideoView(Context context){
super(context);
}
public void resizeVideo(int width,int height){
_overrideHeight = height;
_overrideWidth = width;
// not sure whether it is useful or not but safe to do so
getHolder().setFixedSize(width, height);
requestLayout();
invalidate(); // very important, so that onMeasure will be
triggered
}
@Override
protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
{
setMeasuredDimension(_overrideWidth,_overrideHeight);
}
}
And the code of the main activity that is making the region grow...
int startWidth = 480;
int startHeight = 240;
int endWidth = 480;
int endHeight = 400;
int stepSize = 5;
long sleepAmount = 25;
do {
_panel.setTransparentRegion(new RectF(0, 0, startWidth, startHeight));
_panel.setDrawTransparentRegionOverlay(true);
mVideoView.resizeVideo(startWidth, startHeight);
startWidth+=stepSize;
startHeight+=stepSize;
if (startWidth > endWidth)
startWidth=endWidth;
if (startHeight> endHeight)
startHeight = endHeight;
try {
Thread.sleep(sleepAmount);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} while (startWidth <endWidth || startHeight<endHeight);
_panel.setTransparentRegion(new RectF(0, 0, endWidth, endHeight));
_panel.setDrawTransparentRegionOverlay(false);
mVideoView.resizeVideo(endWidth, endHeight);
Basically everything in the do-loop is ignored by the videoview. Do I have
to run it in a seperate thread or something?
Also. I was thinking that instead of resizing the videoview, I could just
leave the videoview fullscreen, and rescale/transpose/whatever the video
that's being displayed????
Anyways, I'm sure this is all very unclear, but I'd love some advise.
Thx!!!!
Aaron
--
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