I'm seeing an issue that is specific to the Galaxy S6 running Android 5.1.1. I'm using MediaPlayer to play audio streams and on this specific configuration of device and Android version, it fails to ever reach the onPrepared method, and therefore never plays.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAndroidPlayer = new MediaPlayer();
mAndroidPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
System.out.print("ERROR " + i);
return false;
}
});
mAndroidPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
System.out.println("PREPARED");
mAndroidPlayer.start();
}
});
mAndroidPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mAndroidPlayer.setDataSource("http://live.radioart.com/fFilm_scores.mp3");
} catch (IOException e) {
e.printStackTrace();
}
try {
mAndroidPlayer.prepareAsync();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
Just to re-iterate, it works fine on all other devices and Android versions.
Below is output from the console:
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest E/Zygote﹕ MountEmulatedStorage()
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest E/Zygote﹕ v2
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest I/libpersona﹕ KNOX_SDCARD checking this for 10229
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest I/libpersona﹕ KNOX_SDCARD not a persona
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest I/SELinux﹕ Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-G920V_5.1.1_0024
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
09-04 09:54:51.112 24991-24991/com.tsm.mediaplayertest I/art﹕ Late-enabling -Xcheck:jni
09-04 09:54:51.122 24991-24991/com.tsm.mediaplayertest D/TimaKeyStoreProvider﹕ TimaSignature is unavailable
09-04 09:54:51.122 24991-24991/com.tsm.mediaplayertest D/ActivityThread﹕ Added TimaKeyStore provider
09-04 09:54:51.132 24991-24998/com.tsm.mediaplayertest E/art﹕ Failed sending reply to debugger: Broken pipe
09-04 09:54:51.132 24991-24998/com.tsm.mediaplayertest I/art﹕ Debugger is no longer active
09-04 09:54:51.132 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ Inside getClassLibPath + mLibMap{0=, 1=}
09-04 09:54:51.132 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ Inside getClassLibPath caller
09-04 09:54:51.142 24991-24991/com.tsm.mediaplayertest D/InjectionManager﹕ InjectionManager
09-04 09:54:51.142 24991-24991/com.tsm.mediaplayertest D/InjectionManager﹕ fillFeatureStoreMap com.tsm.mediaplayertest
09-04 09:54:51.142 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ Constructor com.tsm.mediaplayertest, Feature store :{}
09-04 09:54:51.142 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ featureStore :{}
09-04 09:54:51.162 24991-24991/com.tsm.mediaplayertest D/SecWifiDisplayUtil﹕ Metadata value : SecSettings2
09-04 09:54:51.172 24991-24991/com.tsm.mediaplayertest D/PhoneWindow﹕ *FMB* installDecor mIsFloating : false
09-04 09:54:51.182 24991-24991/com.tsm.mediaplayertest D/PhoneWindow﹕ *FMB* installDecor flags : -2139029248
09-04 09:54:51.202 24991-24991/com.tsm.mediaplayertest I/MediaPlayer﹕ Need to enable context aware info
09-04 09:54:51.202 24991-24991/com.tsm.mediaplayertest V/MediaPlayer-JNI﹕ native_setup
09-04 09:54:51.202 24991-24991/com.tsm.mediaplayertest V/MediaPlayer﹕ constructor
09-04 09:54:51.202 24991-24991/com.tsm.mediaplayertest V/MediaPlayer﹕ setListener
09-04 09:54:51.202 24991-24991/com.tsm.mediaplayertest V/MediaPlayer-JNI﹕ setAudioStreamType: 3
09-04 09:54:51.202 24991-24991/com.tsm.mediaplayertest V/MediaPlayer﹕ MediaPlayer::setAudioStreamType
09-04 09:54:51.212 24991-24991/com.tsm.mediaplayertest V/MediaPlayer﹕ setVideoSurfaceTexture
09-04 09:54:51.212 24991-24991/com.tsm.mediaplayertest V/MediaPlayer﹕ prepareAsync
09-04 09:54:51.212 24991-24991/com.tsm.mediaplayertest D/Activity﹕ performCreate Call Injection manager
09-04 09:54:51.212 24991-25004/com.tsm.mediaplayertest D/MediaHTTPConnection﹕ setReadTimeOut = 30000ms
09-04 09:54:51.212 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ dispatchOnViewCreated > Target : com.tsm.mediaplayertest.MainActivity isFragment :false
09-04 09:54:51.212 24991-25010/com.tsm.mediaplayertest D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest D/MediaHTTPConnection﹕ setReadTimeout with 30000ms
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest I/System.out﹕ (HTTPLog)-Static: isShipBuild true
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest I/System.out﹕ (HTTPLog)-Thread-5351-996493763: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest I/System.out﹕ (HTTPLog)-Thread-5351-996493763: SMARTBONDING_FEATURE_ENABLED is true
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
09-04 09:54:51.222 24991-25004/com.tsm.mediaplayertest I/System.out﹕ KnoxVpnUidStorageknoxVpnSupported API value returned is false
09-04 09:54:51.222 24991-24991/com.tsm.mediaplayertest D/PhoneWindow﹕ *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
09-04 09:54:51.222 24991-24991/com.tsm.mediaplayertest D/PhoneWindow﹕ *FMB* isFloatingMenuEnabled return false
09-04 09:54:51.242 24991-24991/com.tsm.mediaplayertest D/SRIB_DCS﹕ log_dcs ThreadedRenderer::initialize entered!
09-04 09:54:51.262 24991-25010/com.tsm.mediaplayertest D/libEGL﹕ loaded /vendor/lib/egl/libGLES_mali.so
09-04 09:54:51.272 24991-25010/com.tsm.mediaplayertest I/OpenGLRenderer﹕ Initialized EGL, version 1.4
09-04 09:54:51.282 24991-25010/com.tsm.mediaplayertest I/OpenGLRenderer﹕ HWUI protection enabled for context , &this =0xf4d8c940 ,&mEglDisplay = 1 , &mEglConfig = -185126244
09-04 09:54:51.282 24991-25010/com.tsm.mediaplayertest D/OpenGLRenderer﹕ Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
09-04 09:54:51.282 24991-25010/com.tsm.mediaplayertest D/OpenGLRenderer﹕ Enabling debug mode 0
09-04 09:54:51.282 24991-25010/com.tsm.mediaplayertest D/mali_winsys﹕ new_window_surface returns 0x3000, [1440x2560]-format:1
09-04 09:54:51.292 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ dispatchCreateOptionsMenu :com.tsm.mediaplayertest.MainActivity
09-04 09:54:51.292 24991-24991/com.tsm.mediaplayertest I/InjectionManager﹕ dispatchPrepareOptionsMenu :com.tsm.mediaplayertest.MainActivity
09-04 09:54:51.322 24991-24991/com.tsm.mediaplayertest I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@356f9c4b time:29488057
09-04 09:54:51.672 24991-25004/com.tsm.mediaplayertest I/MediaHTTPConnection﹕ response code = 200
09-04 09:54:51.672 24991-25004/com.tsm.mediaplayertest V/MediaHTTPConnection﹕ mTotalSize is -1
09-04 09:54:51.672 24991-25004/com.tsm.mediaplayertest D/MediaHTTPConnection﹕ getProperties 16
09-04 09:54:51.672 24991-25013/com.tsm.mediaplayertest D/MediaHTTPConnection﹕ getProperties 16
09-04 09:54:52.142 24991-24998/com.tsm.mediaplayertest I/art﹕ Ignoring second debugger -- accepting and dropping
It's a partial solution but to my mind it's the most perenne solution. MediaPlayer has been created a long time ago, and therefore is not very flexibile as we want it. I have been using Exoplayer from one year now and last version come with audio playback only. So I guess if you change your implementation of your audio player to use Exoplayer it will solve most issue and later issue.
Exoplayer is a powerfull player from google developers, available as an external librarie so you don't have to manage buggy implementation on some Android version.
Exoplayer GitHub
Exoplayer developer guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With