[英]Video live streaming pause not working in android
In my app i am using video view for playing live streaming.Here is the code i am using to play the video. 在我的应用程序中,我使用视频视图播放实时流媒体,这是我用来播放视频的代码。
try {
String http_url="rtsp://live.wmncdn.net/jiljillive/bbb19eae240ec100af921d511efc86a0.sdp";
videoView = (VideoView) findViewById(R.id.videoView1);
Uri video = Uri.parse(http_url);
videoView.setVideoURI(video);
videoView.start();
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(this, "Error connecting", Toast.LENGTH_SHORT).show();
}
I used videoView.pause() to pause the video.But unfortunately the video not paused when i click the button. 我使用videoView.pause()暂停了视频。但是不幸的是,当我单击按钮时,视频没有暂停。
Please give the solution for pause the live video streaming. 请提供暂停直播视频流的解决方案。
you need to add these in your code for pause
the video: 您需要在代码中添加以下内容以
pause
视频:
LiveStreamFragment.java: LiveStreamFragment.java:
private MediaController mediaController;
public class LiveStreamFragment extends Fragment implements OnPreparedListener,
MediaController.MediaPlayerControl {
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnPreparedListener(this);
@Override
public void onPause() {
super.onPause();
mediaController.hide();
}
public void pause() {
mediaPlayer.pause();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.