Android - 动画完成视频后没有播放

时间:2013-12-28 08:35:22

标签: android animation android-videoview

我是android的新手。我想在动画后播放视频,但在播放动画视频之前,在播放动画视频后,我已经使用了动画侦听器,它也不适用于我。

public class MainActivity extends Activity{

    ImageView image;
    VideoView video;
    ImageButton play;
    RelativeLayout videolay;
    Animation LR;
    ZoomView zoomview;
    String uriPath = null;
    static boolean playpause = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        image = (ImageView) findViewById(R.id.image);
        video = (VideoView) findViewById(R.id.video);
        play = (ImageButton) findViewById(R.id.play);
        videolay = (RelativeLayout) findViewById(R.id.videolay);
        zoomview = (ZoomView) findViewById(R.id.zoomlay);

        LR = AnimationUtils.loadAnimation(this, R.anim.move);
        videolay.startAnimation(LR);

        LR.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                uriPath = "android.resource://" +        MainActivity.this.getPackageName() + "/" + "raw/video";
                Log.v("uripath",""+uriPath);
            MediaController ctrl = new    MediaController(MainActivity.this);
                ctrl.setVisibility(View.GONE);
                video.setMediaController(ctrl);
                video.setVideoURI(Uri.parse(uriPath));

            }
        });


        video.setOnTouchListener(new OnTouchListener()
        {
            @Override
            public boolean onTouch(View v, MotionEvent event) 
            {
                video.pause();
                playpause = false;
                play.setVisibility(View.VISIBLE);
                return false;
            }
        });

        play.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v) 
            {
                Log.v("buttonclicked","");
                if(playpause == false)
                {
                    video.start();
                    Log.v("videostarted","");
                    playpause = true;
                    play.setVisibility(View.GONE);
                }
            }
        });
    }




    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }



    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

请帮忙解决这个问题。

0 个答案:

没有答案