我正在尝试播放动画后的视频,但在播放动画视频之前,在播放动画视频后,我使用了动画侦听器,它也不适用于我。
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;
}
}
请帮忙解决这个问题。