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 android.graphics.Matrix;
  2. import android.view.animation.Animation;
  3. import android.view.animation.LinearInterpolator;
  4. import android.view.animation.Transformation;
  5.  
  6. public class ViewAnimation extends Animation
  7. {
  8.         float centerX, centerY;
  9.     public ViewAnimation(){}
  10.    
  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.     }
  21.    
  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. }
  31.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4



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(R.id.surface);
  3. s.startAnimation(new ViewAnimation()); 
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

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!
wjspoel
Junior Developer
Junior Developer
 
Posts: 18
Joined: Thu Dec 24, 2009 10:40 pm

Top

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

I have same problem with it, couldnt figure out the problem yet..
tominm
Freshman
Freshman
 
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...
wjspoel
Junior Developer
Junior Developer
 
Posts: 18
Joined: Thu Dec 24, 2009 10:40 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 18 guests