Reputation: 1023
When i try to play stream music via Medialayer, i get this msgs:
05-18 18:24:30.371 23988-23988/my.package.name D/MediaPlayer﹕ setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: http://stream6.radiostyle.ru:8006/priboyfm
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1074)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:927)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:854)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1085)
at my.package.name.radio05.radio.PlayService.prepareRadioAt(PlayService.java:149)
at my.package.name.radio05.radio.PlayService.onStartCommand(PlayService.java:108)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3307)
at android.app.ActivityThread.access$2200(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
But in 2-5mins after onPreparedListener playing begin.
For test I create a new project with only MediaPlayer and test again - same problem, but on anothers apps (online radio, online music) all working perfect, tested different apps.
p.s. Early all working nice, i think it's bug of Android 5, because on android 4.* working nice (playing starts after 10-20 seconds) also on emulator playings starts right after onPreparedListener
New logcat:
05-18 19:31:57.461 22893-22893/? V/MediaPlayer-JNI﹕ native_setup
05-18 19:31:57.461 22893-22893/? V/MediaPlayer﹕ constructor
05-18 19:31:57.466 22893-22893/? V/MediaPlayer﹕ setListener
05-18 19:31:57.466 22893-22893/? V/MediaPlayer-JNI﹕ setAudioStreamType: 3
05-18 19:31:57.466 22893-22893/? V/MediaPlayer﹕ MediaPlayer::setAudioStreamType
05-18 19:31:57.481 22893-22893/? V/MediaPlayer﹕ setVideoSurfaceTexture
05-18 19:31:57.481 22893-22893/? V/MediaPlayer﹕ prepare
05-18 19:31:57.541 22893-22902/my.package.test I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-18 19:31:57.541 22893-22902/my.package.test I/System.out﹕ (HTTPLog)-Static: isShipBuild true
05-18 19:31:57.541 22893-22902/my.package.test I/System.out﹕ (HTTPLog)-Thread-101145-825770595: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-18 19:31:57.541 22893-22902/my.package.test I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-18 19:31:58.491 22893-22902/my.package.test I/System.out﹕ KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-18 19:31:59.046 22893-22902/my.package.test V/MediaHTTPConnection﹕ mTotalSize is -1
05-18 19:31:59.051 22893-22902/my.package.test D/MediaHTTPConnection﹕ setReadTimeOut = 30000ms
05-18 19:32:26.646 22893-22955/my.package.test V/MediaPlayer﹕ message received msg=200, ext1=973, ext2=0
05-18 19:32:26.646 22893-22955/my.package.test W/MediaPlayer﹕ info/warning (973, 0)
05-18 19:32:26.646 22893-22955/my.package.test V/MediaPlayer﹕ callback application
05-18 19:32:26.646 22893-22955/my.package.test V/MediaPlayer﹕ back from callback
05-18 19:32:26.646 22893-22955/my.package.test V/MediaPlayer﹕ message received msg=1, ext1=0, ext2=0
05-18 19:32:26.651 22893-22955/my.package.test V/MediaPlayer﹕ prepared
05-18 19:32:26.651 22893-22955/my.package.test V/MediaPlayer﹕ signal application thread
05-18 19:32:26.651 22893-22955/my.package.test V/MediaPlayer﹕ callback application
05-18 19:32:26.651 22893-22955/my.package.test V/MediaPlayer﹕ back from callback
05-18 19:32:26.651 22893-22893/my.package.test V/MediaPlayer﹕ prepare complete - status=0
05-18 19:32:26.651 22893-22893/my.package.test E/MediaPlayer﹕ Should have subtitle controller already set
05-18 19:32:26.651 22893-22893/my.package.test V/MediaPlayer-JNI﹕ start
05-18 19:32:26.651 22893-22893/my.package.test V/MediaPlayer﹕ start
05-18 19:32:26.656 22893-22893/my.package.test D/Activity﹕ performCreate Call secproduct feature valuefalse
05-18 19:32:26.656 22893-22893/my.package.test D/Activity﹕ performCreate Call debug elastic valuetrue
05-18 19:32:26.816 22893-22893/my.package.test V/ActivityThread﹕ updateVisibility : ActivityRecord{21cbc7ea token=android.os.BinderProxy@3c01408c {my.package.test/my.package.test.MainActivity}} show : true
05-18 19:32:26.766 22893-23646/my.package.test D/OpenGLRenderer﹕ Render dirty regions requested: true
05-18 19:32:26.806 22893-22893/my.package.test D/Atlas﹕ Validating map...
05-18 19:32:26.821 22893-22893/my.package.test E/MediaPlayer﹕ Should have subtitle controller already set
05-18 19:32:26.861 22893-23646/my.package.test I/OpenGLRenderer﹕ Initialized EGL, version 1.4
05-18 19:32:26.861 22893-23646/my.package.test W/OpenGLRenderer﹕ Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
05-18 19:32:26.876 22893-23646/my.package.test D/OpenGLRenderer﹕ Get maximum texture size. GL_MAX_TEXTURE_SIZE is 4096
05-18 19:32:26.876 22893-23646/my.package.test D/OpenGLRenderer﹕ Enabling debug mode 0
05-18 19:32:26.876 22893-23646/my.package.test E/﹕ [android_ws] Format: 5, Width: 1080, Height: 1920
05-18 19:32:26.881 22893-23646/my.package.test E/﹕ [android_ws] Format: 5, Width: 1080, Height: 1920
05-18 19:32:26.881 22893-23646/my.package.test E/﹕ [android_ws] Format: 5, Width: 1080, Height: 1920
05-18 19:32:26.881 22893-23646/my.package.test E/﹕ [android_ws] Format: 5, Width: 1080, Height: 1920
05-18 19:32:27.166 22893-22893/my.package.test I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@3c01408c time:136675283
05-18 19:32:27.166 22893-22893/my.package.test I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@3c01408c time:136675283
05-18 19:32:53.916 22893-22893/my.package.test D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN
Upvotes: 2
Views: 12222
Reputation: 21452
you write code by wrong way , you do play music you stream
String url = "http://stream6.radiostyle.ru:8006/priboyfm";
MediaPlayer mPlayer
Buuton buttonPlay = (Button) findViewById(R.id.play);
buttonPlay.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// editing
if(mPlayer == null){
mPlayer = new MediaPlayer();
}
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(url);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
}
mPlayer.start();
}
});
// Update answer
private void play_music_onReady(){
// pass your url here
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), Uri.parse(url));
mp.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
}
make sure you have iternet permission
<uses-permission android:name="android.permission.INTERNET"/>
Upvotes: 1