2011-07-19 20 views
7

私はアニメーション付きvideoviewを使用しています(video.setAnimation(slideinRight);)ビデオではなく、ビデオビューのレイアウトのみがアニメーション化されています。翻訳アニメーションが発生すると、ボックスの移動とビデオ上のマスクが表示されますが、ビデオは決して移動しません。私は今何をすべきか迷っています。VideoView Animation

答えて

2

かなり遅く、これを答えるために申し訳ありませんが、それは価値がある何のため。 「スライド」アニメーションだけを使用している場合は、 ビデオビューをレイアウトに配置し、レイアウトをアニメーション化してみてください。

私のコードで設定した方法は次のとおりです。

次に、ビデオビューをアニメーション化してスライドさせる場所。

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

これは3.1アニメーションシステムです。

アニメーションの古典的な2.1方法は、このように動作することはわかりませんが、同じように機能するはずです。

レイアウトの回転/拡大縮小のようなものは機能しません。レイアウトをパニングしてフェードアウトすることは、動作する唯一のものではないようです。 TextureView here

詳細参照:

5

現在、私はVideoViewにアニメーションを配置しようとしています。

VideoViewは、MediaPlayerと基本的にはa SurfaceViewであり、プレーヤーの状態マシンの基本的な管理があります。

実は、「描く」本当の仕事は私たちが別のデバイス上でアニメーションをテストし、VideoViewのことがわかってきました

(あなたのAndroidデバイス上のリアルプレーヤーエンジンの実装別名)のMediaPlayerでネイティブメソッドによって処理されるようです基本的なビデオプレーヤーの行動/実装が異なるのAndroidデバイス間で同じではありません。

  • いくつかのデバイスが正しく
  • 他人はいけない、とだけぼかし、黒画面、またはバグの表示を表示し、プレイヤーの視点アニメーションを扱います。.. 。

VideoViewはメモリに直接書き込まれているように見えるので、不透明なビューを前面に置き、そのビューでアニメーションを設定するなどの「回避策」は機能していないようです。

私はこの上で他人からのフィードバックを持って喜んでいると思います:)

+0

解決方法を見つけられましたか? –

+0

いいえ、私たちはアプリケーションのために別のデザインを実装しなければなりませんでした(VideoViewを動かすのではなく、他の部分を動かす必要がありました:-)しかし、アンドロイド4.0でコードがどのように進化したのだろうか。それを見てください... – Vinzzz

+0

私はいくつかのデバイスがOpenGLの正しいサポートを持っていないと思う。この場合、デバイスはぼかしまたは黒い画面を表示しています –

1

単にTextureViewを使用しています。 TextureViewZoomOutアニメーション -

私はZoomInを行っています。>アニメーションフォルダ -

RESアニメーションXMLを追加します。

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) { 

    } 
} 

完了