java - Android - MediaPlayer's on Prepare Called even before the stream is prepared on Android 4.0+ -
i facing issue whenever stream played app on android 4.0+ onprepare
method mediaplayer.onpreparedlistener
called before stream loaded , unable indicated user stream downloading/buffering in process. i have found question of same kind not answered here doing.
@override public void oncreate(final bundle savedinstancestate) { super.oncreate(savedinstancestate); playvideo(somertspurl); } private void playvideo(string url) { // if app running on google tv change rtsp link hls if (url.contains("rtsp")) { // split rtsp url , make 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(); }
this code working fine on google tv , other android 3.0+ , < 4.0+ device
i don't have experience media player. couple of suggestions/queries side
- no call prepare. if doing it, did try prepareasync ?
- you not using mediaplayer instance passed onprepared callback. there can chance trying start wrong mediaplayer.
Comments
Post a Comment