Android Media Player Url specific issue -
i working in 1 of android project in playing sound media player. when use this url playing song ioexception follow song playing fine in mediaplayer. should problem?
public void startmediaplayer(string url) { log.e("urltoplay==>",url); // start new song play if(mediaplayer==null){ mediaplayer=new mediaplayer(); }else{ mediaplayer.reset(); } uri myuri1 = uri.parse(url); mediaplayer.setaudiostreamtype(audiomanager.stream_music); try { mediaplayer.setdatasource(getactivity(), myuri1); mediaplayer.prepareasync(); mediaplayer.setonpreparedlistener(new onpreparedlistener() { @override public void onprepared(mediaplayer player) { playpause=true; player.start(); mediafilelengthinmilliseconds = player.getduration(); // gets song length in milliseconds url } }); mediaplayer.setoncompletionlistener(new oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { playpause=false; } }); mediaplayer.setonerrorlistener(new onerrorlistener() { @override public boolean onerror(mediaplayer arg0, int arg1, int arg2) { log.e("onerror==>","something went wrong"+arg1+""); log.e("onerror==>","something went wrong"+arg2+""); return false; } }); } catch (illegalargumentexception e) { e.printstacktrace(); mediaplayer.release(); } catch (securityexception e) { e.printstacktrace(); mediaplayer.release(); } catch (illegalstateexception e) { e.printstacktrace(); mediaplayer.release(); } catch (ioexception e) { e.printstacktrace(); mediaplayer.release(); } }
i got following exception while playing file
06-01 15:30:24.758: d/mediaplayer(12450): setdatasource ioexception happend : 06-01 15:30:24.758: d/mediaplayer(12450): java.io.filenotfoundexception: no content provider: http://pleer.com/browser-extension/files/72338325d4w.mp3 06-01 15:30:24.758: d/mediaplayer(12450): @ android.content.contentresolver.opentypedassetfiledescriptor(contentresolver.java:1053) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.content.contentresolver.openassetfiledescriptor(contentresolver.java:907) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.content.contentresolver.openassetfiledescriptor(contentresolver.java:834) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.media.mediaplayer.setdatasource(mediaplayer.java:969) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.media.mediaplayer.setdatasource(mediaplayer.java:923) 06-01 15:30:24.758: d/mediaplayer(12450): @ com.hyper.musicapp.fragments.searchfragmentmusic.startmediaplayer(searchfragmentmusic.java:998) 06-01 15:30:24.758: d/mediaplayer(12450): @ com.hyper.musicapp.fragments.searchfragmentmusic$searchsoundcloudtrackadapter$1.onclick(searchfragmentmusic.java:473) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.view.view.performclick(view.java:4639) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.view.view$performclick.run(view.java:19252) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.os.handler.handlecallback(handler.java:733) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.os.handler.dispatchmessage(handler.java:95) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.os.looper.loop(looper.java:146) 06-01 15:30:24.758: d/mediaplayer(12450): @ android.app.activitythread.main(activitythread.java:5511) 06-01 15:30:24.758: d/mediaplayer(12450): @ java.lang.reflect.method.invokenative(native method) 06-01 15:30:24.758: d/mediaplayer(12450): @ java.lang.reflect.method.invoke(method.java:515) 06-01 15:30:24.758: d/mediaplayer(12450): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1283) 06-01 15:30:24.758: d/mediaplayer(12450): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1099) 06-01 15:30:24.758: d/mediaplayer(12450): @ dalvik.system.nativestart.main(native method) 06-01 15:30:24.758: d/mediaplayer(12450): couldn't open file on client side, trying server side
try add url scheme "file://
" or "http://
". worked me when got same exception trying play local file.
Comments
Post a Comment