当剪辑结束并再次开始剪辑时,如何使视频无缝循环
`public class TvPlay extends Activity实现OnCompletionListener, OnErrorListener,OnPreparedListener {
private VideoView mVideoView;
private String url;
private ProgressBar load;
private TextView empty;
private AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// Vitamio.isInitialized(this); Vitamio.isInitialized(getApplicationContext());
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.tvplay);
mAdView = (AdView) findViewById(R.id.adView);
mAdView.loadAd(new AdRequest.Builder().build());
Log.d("url=", getIntent().getStringExtra("url"));
url = getIntent().getStringExtra("url");
init();
}
public void init() {
load = (ProgressBar) this.findViewById(R.id.load);
empty = (TextView) this.findViewById(R.id.empty);
mVideoView = (VideoView) this.findViewById(R.id.surface_view);
mVideoView.setOnCompletionListener(this);
mVideoView.setOnPreparedListener(this);
mVideoView.setOnErrorListener(this);
Uri videoUri = Uri.parse(url);
mVideoView.setVideoURI(videoUri);
mVideoView.requestFocus();
loading();
}
private void loading() {
load.setVisibility(View.GONE);
empty.setVisibility(View.GONE);
}
private void loadComplete(MediaPlayer arg0) {
load.setVisibility(View.GONE);
// vv.setVisibility(View.VISIBLE);
empty.setVisibility(View.GONE);
mVideoView.start();
mVideoView.resume();
}
private void error(String msg) {
load.setVisibility(View.GONE);
mVideoView.setVisibility(View.GONE);
empty.setVisibility(View.VISIBLE);
if (msg != null)
empty.setText(msg);
}
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
Log.d("ONLINE TV", "Prepared");
loadComplete(mp);
}
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
// TODO Auto-generated method stub
Log.d("ONLINE TV", "Error");
error("Unable to play this channel.");
return false;
}
@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
Log.d("ONLINE TV", "Complete");
}
}
`
答案 0 :(得分:0)
这将使您的视频继续播放
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});