Animation video review

I use a video review with animation (video.setAnimation (slideinRight);) Everything works fine, except that when switching only the animation of the video image is animated, not the video. When translational animation occurs, I see the box moving and masking over my video, but the video never moves with it. I am at a loss what to do now.

+7
source share
3 answers

Itโ€™s a pity that I answered it quite late, but for what it costs. and if you want to use the slide animation. Try placing the video in a layout and animate the layout.

The way it was configured in my code:

AbsoluteLayout Animationlayout = (AbsoluteLayout)findViewById(R.string.frontlayout); VideoView pvv = new VideoView(getApplicationContext()); pvv.getHolder().addCallback(this); Animationlayout.addView(pvv); // load video data in pvv. 

Then, when you want to animate your video for a slide;

 Animationlayout.animate().xBy(25).setDuration(500).setInterpolator(new BounceInterpolator()); 

Please note that this is an animation system 3.1.

Not sure if classic 2.1 animation will work like that, but it should serve the same.

Material such as rotation / scaling of the layout will not work. The panorama of the layout around and the fading out seem to be just a few things that work.

+2
source

I'm currently trying to put an animation in a VideoView.

If you look at the source code for Android, VideoView is basically SurfaceView , combined with MediaPlayer with basic player state machine control.

In fact, the real work of โ€œdrawingโ€ is apparently handled by the built-in methods in mediaPlayer (aka the implementation of the game engine on your Android device).

We tested the animation on different devices and found that the behavior / implementation of the VideoView video player is not the same among different Android devices:

  • Some devices correctly handle player viewing animations.
  • others DO NOT, and simply display blur, a black screen or a buggy display ...

In addition, VideoView seems to be written directly to memory, so any โ€œworkaroundโ€ (for example, an opaque front view and animation settings on this view) does not seem to work.

I would be glad if other reviews were addressed to this :)

+5
source

Just use TextureView :

More links to TextureView here .

I did a ZoomIn - ZoomOut animation in a TextureView .

Add the xml animation to the Res โ†’ anim folder.

zoom_in_out.xml

 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <scale android:duration="1000" android:fillAfter="false" android:fromXScale="1.0" android:fromYScale="1.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.2" android:toYScale="1.2" /> <set android:interpolator="@android:anim/decelerate_interpolator"> <scale android:duration="1000" android:fillBefore="false" android:fromXScale="1.2" android:fromYScale="1.2" android:pivotX="50%" android:pivotY="50%" android:startOffset="500" android:toXScale="1.0" android:toYScale="1.0" /> </set> </set> 

texture_layout.xml

 <?xml version="1.0" encoding="utf-8"?> <TextureView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textureView" android:layout_margin="50dp" android:background="@android:color/darker_gray" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextureView> 

TextureViewActivity.java

 import android.graphics.SurfaceTexture; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Surface; import android.view.TextureView; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import java.io.IOException; public class TextureViewActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener { private TextureView textureView; private MediaPlayer mMediaPlayer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.texture_layout); textureView = (TextureView)findViewById(R.id.textureView); textureView.setSurfaceTextureListener(this); textureView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Animation zoomAnimation = AnimationUtils.loadAnimation(TextureViewActivity.this, R.anim.zoom_in_out); textureView.startAnimation(zoomAnimation); } }); } private String getVideoPath(){ return "android.resource://" + getPackageName() + "/" + R.raw.promovideo; } @Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { Surface surface = new Surface(surfaceTexture); try { mMediaPlayer= new MediaPlayer(); mMediaPlayer.setDataSource(TextureViewActivity.this, Uri.parse(getVideoPath())); mMediaPlayer.setSurface(surface); mMediaPlayer.prepare(); mMediaPlayer.start(); mMediaPlayer.setLooping(true); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { return false; } @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) { } } 

Done

+1
source

All Articles