1

I would like to make a small video (about 4 seconds) repeat until webview finishes loading the desired URL in the background. Right now the video plays once, then a blank black screen comes up until the page loads. I'm still pretty new to this... Thanks in advance for any help! Sorry for the EDITED stuff, but it was necessary.

Here is my splash java

package com.EDITED;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.widget.VideoView;

public class Splash extends Activity implements OnCompletionListener
{
VideoView videoView;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
VideoView video = (VideoView) findViewById(R.id.videoView);

videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        mp.setLooping(true);
    }
});

video.setVideoPath("android.resource://com.EDITED/raw/" + R.raw.splash);
video.start();
}

@Override
public void onCompletion(MediaPlayer mp)
{
    Intent intent = new Intent(this, EDITEDActivity.class);
    startActivity(intent);
    finish();
}
}
4

1 回答 1

0

基本上你创建一个AsyncTask来做加载和 onPostExecute(Long 结果) 你停止视频。

还可以循环播放视频,您可以使用

public class Splash extends Activity implements OnCompletionListener
{
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    VideoView video = (VideoView) findViewById(R.id.videoView);

    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });

    video.setVideoPath("android.resource://com.EDITED/raw/" + R.raw.splash);
    video.start();
}

}
于 2012-05-27T21:29:42.333 回答