I have a pretty standard media glider object that runs in onCreate and loops for background music in my application. The file is not unusually large, it's 6 MB MP3. From onCreate:
MediaPlayer mp; mp = MediaPlayer.create(MainActivity.this, R.raw.lostmexicancity); mp.setLooping(true); mp.setVolume(0.4f, 0.4f); mp.start();
This works very well on most of my test devices, including older phones, the Samsung Galaxy Tab 2 10 "tablet, and even the Nexus 4.
Unfortunately, I experience problems exclusively with newer devices, where I encounter a sound / stutter failure on the Nexus 5 and the new Nexus 10. These problems ONLY happen on new devices, usually after a few seconds of correct playback, and not immediately. Both of my Nexus 4 and 5 are running Android 4.4.4, but the problem remains only on the Nexus 5.
These problems seem to be exacerbated when I pause the media glider object and play for a short period of time (combat music for short fights in the game), but the crash occurs even without this additional complication.
I read that new versions of Android caused problems with Mediaplayer, but I did not come up with a fix or suggestion.
Has anyone else experienced this problem, who can suggest a fix or workaround? Thank you for your time!
source share