gpt4 book ai didi

Android 检查视频流结束

转载 作者:行者123 更新时间:2023-11-30 03:36:33 24 4
gpt4 key购买 nike

我有这个简单的视频流播放器:

    if (play) {

myVideoView.stopPlayback();
myVideoView.clearFocus();
myVideoView = null;


button5.setText("Start");
play = false;
} else {
// dialog = ProgressDialog.show(Main.this, "Feldolgozás",
// "A videó töltődik");
progressBar = new ProgressDialog(v.getContext());
progressBar.setCancelable(true);
progressBar.setMessage("A video töltődik ...");
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);
progressBar.setMax(100);
progressBar.show();

myVideoView = (VideoView) findViewById(R.id.myvideoview);
myVideoView.setVideoURI(Uri.parse(SrcPath));
RelativeLayout.LayoutParams videoviewlp = new RelativeLayout.LayoutParams(
500, 480);
videoviewlp.addRule(RelativeLayout.CENTER_HORIZONTAL,
RelativeLayout.TRUE);
videoviewlp.addRule(RelativeLayout.CENTER_VERTICAL,
RelativeLayout.TRUE);
myVideoView.setLayoutParams(videoviewlp);
myVideoView.invalidate();
myVideoView.requestFocus();

myVideoView.setOnPreparedListener(new OnPreparedListener() {

public void onPrepared(MediaPlayer mp) {
// mp.setOnCompletionListener(this);
mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(
MediaPlayer mPlayer, int percent) {

progressBar.setProgress(percent);

if (percent == 100) {
//dialog.dismiss();
progressBar.dismiss();
// Toast.makeText(getApplicationContext(),
// "100%", Toast.LENGTH_LONG).show();
}

}
});

mp.start();

// myVideoView.start();

}

});


play = true;
button5.setText("Stop");



}
}

如何检查视频流是否已结束或丢失?如果丢失按钮应更改为开始和停止视频查看...回答你的问题!

更新: 我认为问题出在 vlc rtsp 流上,因为它表示 youtube rtsp 何时结束...

最佳答案

您可以尝试使用以下 VideoView 监听器:

public void setOnCompletionListener (MediaPlayer.OnCompletionListener l)

Register a callback to be invoked when the end of a media file has been reached during playback.

public void setOnErrorListener (MediaPlayer.OnErrorListener l)

Register a callback to be invoked when an error occurs during playback or setup. If no listener is specified, or if the listener returned false, VideoView will inform the user of any errors.

More Information

关于Android 检查视频流结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16591031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com