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

  1. no call prepare. if doing it, did try prepareasync ?
  2. you not using mediaplayer instance passed onprepared callback. there can chance trying start wrong mediaplayer.

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -