我正在尝试制作一个直播电视应用程序,但当我播放.mp4链接时,mediacontroller播放/暂停按钮工作,但当我尝试播放.m3u8链接时,播放/暂停按钮不工作。我是 java 新手。。。这是密码。
private void playVideo() {
try {
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
String videoUrl = "http://My_HLS_Link.m3u8";
Uri videoUri = Uri.parse(videoUrl);
videoView.setVideoURI(videoUri);
videoView.requestFocus();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
mediaController.show(0);
pd.dismiss();
videoView.start();
}
});
}
catch (Exception e) {
pd.dismiss();
Toast.makeText(this, "Time Out! Please Try Again"+e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
`
暂无答案!
目前还没有任何答案,快来回答吧!