Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用VideoView.isPlaying()方法?_Java_Android - Fatal编程技术网

Java 如何使用VideoView.isPlaying()方法?

Java 如何使用VideoView.isPlaying()方法?,java,android,Java,Android,我的目标是在视频播放期间播放一个重复的动画,因为我使用的是VideoView,我想我最好利用.isplay方法来解决这个问题,实现这个,但是while循环根本不执行 Floater0 = (ImageView) findViewById(R.id.Floater0); AdPlayer0 = (VideoView) findViewById(R.id.AdPlayer); ConvertedSource = Uri.parse("android.resource://"

我的目标是在视频播放期间播放一个重复的动画,因为我使用的是VideoView,我想我最好利用.isplay方法来解决这个问题,实现这个,但是while循环根本不执行

    Floater0 = (ImageView) findViewById(R.id.Floater0);
    AdPlayer0 = (VideoView) findViewById(R.id.AdPlayer);

    ConvertedSource = Uri.parse("android.resource://"+ getPackageName()+ "/" + R.raw.kitkat);
    AdPlayer0.setVideoURI(ConvertedSource);
    AdPlayer0.start();

    while (AdPlayer0.isPlaying()){
        TranslateAnimation animation = new TranslateAnimation(answer,  answer, 0,  height * -1); // xfrom , xto, y from,y to
        animation.setDuration(5000);  // animation duration influences the speed of full execution
        Floater0.setVisibility(View.VISIBLE); //show it
        Floater0.startAnimation(animation);  // start animation

    }
视频播放成功,但动画没有出现,我已确保动画的实施,并已通过简单地将其放置在循环的大括号外正确,但这不是目的,因为我想重复播放动画时,视频播放

 AdPlayer0.start();

 while (AdPlayer0.isPlaying()){
        TranslateAnimation animation = new TranslateAnimation(answer,  answer, 0,  height * -1); // xfrom , xto, y from,y to
        animation.setDuration(5000);  // animation duration influences the speed of full execution
        Floater0.setVisibility(View.VISIBLE); //show it
        Floater0.startAnimation(animation);  // start animation

    }
可能视频没有时间加载,启动后您直接调用while,但是iPlay应该返回false,因为视频尚未启动。此外,在您创建新动画的while块中,将导致在视频仍在播放时创建多个动画

TranslateAnimation animation = new TranslateAnimation(answer,  answer, 0,  height * -1); // xfrom , xto, y from,y to
animation.setDuration(5000);
Floater0.setVisibility(View.VISIBLE); //show it
Floater0.startAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {
}

@Override
public void onAnimationRepeat(Animation animation) {
}

@Override
public void onAnimationEnd(Animation animation) {
    if (AdPlayer0.isPlaying()) {
        Floater0.startAnimation(animation);
    }
}
可能视频没有时间加载,启动后您直接调用while,但是iPlay应该返回false,因为视频尚未启动。此外,在您创建新动画的while块中,将导致在视频仍在播放时创建多个动画

TranslateAnimation animation = new TranslateAnimation(answer,  answer, 0,  height * -1); // xfrom , xto, y from,y to
animation.setDuration(5000);
Floater0.setVisibility(View.VISIBLE); //show it
Floater0.startAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {
}

@Override
public void onAnimationRepeat(Animation animation) {
}

@Override
public void onAnimationEnd(Animation animation) {
    if (AdPlayer0.isPlaying()) {
        Floater0.startAnimation(animation);
    }
}
对于您的视频视图,请使用setOnCompletionListener查找以完成视频播放。在该侦听器中,停止动画并隐藏Floater0.setVisibility(View.GONE)


对于您的视频视图,请使用setOnCompletionListener查找以完成视频播放。在该侦听器中,停止动画并隐藏Floater0.setVisibility(View.GONE)

我认为您只需要删除while(AdPlayer0.isPlaying()){

添加
animation.setRepeatCount(animation.INFINITE);

等等

    animation.setAnimationListener(new AnimationListener() {
    @Override
    public void onAnimationEnd(Animation arg0) {
        Floater0.stopAnimation(animation);
}

我认为您只需要删除while(AdPlayer0.isPlaying()){

添加
animation.setRepeatCount(animation.INFINITE);

等等

    animation.setAnimationListener(new AnimationListener() {
    @Override
    public void onAnimationEnd(Animation arg0) {
        Floater0.stopAnimation(animation);
}

你可以在视频的同时统计循环动画,在videoView onCompletionListner中,只需停止动画你可以在视频的同时统计循环动画,在videoView onCompletionListner中,只需停止动画好的一点,但是我如何才能买到更多的时间,你认为Dindini answer为我赢得了我需要的时间吗?是的Dinnii的解决方案很完美很好,但是我怎么才能赢得更多的时间呢,你认为Dinnii的回答给我赢得了我所需要的时间吗?是的,Dinnii的解决方案很完美对不起,我遗漏了一个细节,我正在动态地改变动画的参数,因此简单地重复动画是不行的!对不起,我不知道这一点我遗漏的是,我正在动态地改变动画的参数,因此简单地重复动画是不行的!很抱歉,我不知道这一点。