我面临的问题是,只要我的应用程序在
Android 4.0上播放流,就会在加载流之前调用MediaPlayer.OnPreparedListener的OnPrepare方法,因此我无法向用户表明流下载/缓冲正在进行中.
I have already found a question of the same kind but not answered
这是我正在做的事情.
这是我正在做的事情.
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); playVideo(someRtspUrl); } private void playVideo(String url) { // if app is running on Google TV then change RTSP link to HLS if (url.contains("rtsp")) { // split the RTSP URL and make it as HLS String videoUrlParts[] = url.split("\\?"); url = videoUrlParts[0].replace("rtsp","http") + "/playlist.m3u8"; if (videoUrlParts.length > 1) url += "?" + videoUrlParts[1]; } mVideoView.setVideoURI(Uri.parse(url)); mVideoView.requestFocus(); mVideoView.setOnCompletionListener(this); mVideoView.setOnPreparedListener(this); } @Override public void onPrepared(MediaPlayer player) { dismissProgressDialog(); mVideoView.start(); }@H_301_5@此代码在Google TV和其他Android 3.0上运行正常,并且< 4.0设备