Alter video output using tweening animations

All your problems with Audio, Video and Images.

Alter video output using tweening animations

Postby wjspoel » Sat Jan 02, 2010 1:54 pm

Hi All,

first my question: Is it possible to change video output using the animations framework? For example with the code below it is possible to scale and rotate a ListView, is it possible to apply such matrix operations on a video which is played using a the Mediaplayer and SurfaceView class?

What I have done so far: The video plays using basically this demo code from android developers.

The animation class I am using consist the following code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import;
  2. import android.view.animation.Animation;
  3. import android.view.animation.LinearInterpolator;
  4. import android.view.animation.Transformation;
  6. public class ViewAnimation extends Animation
  7. {
  8.         float centerX, centerY;
  9.     public ViewAnimation(){}
  11.     @Override
  12.     public void initialize(int width, int height, int parentWidth, int parentHeight)
  13.     {
  14.         super.initialize(width, height, parentWidth, parentHeight);
  15.         setDuration(2500);
  16.         setFillAfter(true);
  17.         setInterpolator(new LinearInterpolator());
  18.         this.centerX = width/2;
  19.         this.centerY = height/2;
  20.     }
  22.     @Override
  23.     protected void applyTransformation(float interpolatedTime, Transformation t)
  24.    {
  25.            final Matrix matrix = t.getMatrix();
  26.            matrix.setScale(interpolatedTime, interpolatedTime);
  27.            matrix.preTranslate(-centerX, -centerY);
  28.            matrix.postTranslate(centerX, centerY);
  29.     }
  30. }
Parsed in 0.035 seconds, using GeSHi

Then, I used the following code to apply the animation on the surface view (just like the working ListView)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. //get the surfaceview which the mediaplayer is using
  2. SurfaceView s = (SurfaceView) findViewById(;
  3. s.startAnimation(new ViewAnimation()); 
Parsed in 0.033 seconds, using GeSHi

although the animation code is called, the video continues without any animation...

So, because the SurfaceView is a more advanced view, I looked up about doing animations on a SurfaceView. According to this page, the surface has to be handled using it's holder, and using lockcanvas() and unlockCanvasAndPost() to draw on the surface.
Although drawing something on the video is not my direct goal, it is a start... So I Called those methods. But than I get an error because the SurfaceHolder which the player is using is of type SURFACE_TYPE_PUSH_BUFFERS. changing that type to SURFACE_TYPE_NORMAL results in a black screen.

Because the above listed tries results don't work, it seems to me at the moment that video output can't be altered using animation/matrix operations... Any suggestions?

Thanks in advance!
Junior Developer
Junior Developer
Posts: 18
Joined: Thu Dec 24, 2009 10:40 pm


Postby tominm » Tue Jan 05, 2010 12:46 pm

I have same problem with it, couldnt figure out the problem yet..
Posts: 3
Joined: Tue Jan 05, 2010 12:40 pm

Postby wjspoel » Wed Jan 13, 2010 8:18 pm

Well I think the answer is that it isn't possible. Also an animation invoked on a parent of the surfaceview (Framelayout) works on all his childs, except for the playing surfaceview...
Junior Developer
Junior Developer
Posts: 18
Joined: Thu Dec 24, 2009 10:40 pm


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 19 guests