How do I play a HTTPS audio stream in MediaPlayer on Android[Nexus 5,7] -
our app has stream music network source. question why mediaplayer play when play music using http stream, got error(1,-1004) when use https stream source play in devices. **important:**it got error(1,-1004) in devices, such nexus5, nexus7 , asus fonepad 7.
here snippet :
string url ="http://10.0.0.45/o0$1$8i87308.mp3"; mediaplayer mymediaplayer = new mediaplayer(); mymediaplayer.setaudiostreamtype(audiomanager.stream_music); try { mymediaplayer.setdatasource(url); mymediaplayer.prepareasync(); // might take long! (for buffering, etc) } catch (ioexception e) { toast.maketext(this, "mp3 not found", toast.length_short).show(); e.printstacktrace(); } //mp3 started after completion of preparing... mymediaplayer.setonpreparedlistener(new mediaplayer.onpreparedlistener() { @override public void onprepared(mediaplayer player) { player.start(); system.out.println("onprepared"); } });
Comments
Post a Comment