5

My Android app streams a live audio show using MediaPlayer within a Service. It worked fine until the KitKat 4.4.2 update to Samsung S4 and S5 phones. On these phones, the audio cuts out after about 1 minute. It will start playing again if I hit the stop button, then the play button again, but will continue to cut out again after about a minute. My app thinks it is still playing, but there is no sound.

The live streaming works fine on the other devices I have tested, including a non-Samsung phone running the 4.4.2 OS, and on a 4.4.2 emulator.

After searching stackoverflow, I tried to resolve the issue by

  • targeting API 19
  • adding a wakelock
  • adding a wifilock
  • temporarily commenting out the two timer task threads I have running to update the UI

None of these helped to keep the streaming audio running.

While testing on the Samsung Galaxy S5 phone, I receive MediaPlayer message msg=3 while it is playing, then it changes to msg=2 and then msg=7 right before it stops. I looked at error codes but could not find a 7.

My questions:
1. What is a MediaPlayer msg=7?
2. Has anyone else had trouble with live streaming since the KitKat updates to Samsung S4/S5 phones?

Thank you.

EDIT: PROBLEM APPEARS SOLVED. PLEASE SEE MY COMMENT BELOW.

7/15/14 CORRECTION: It wasn't solved as it just kept looping the same buffered part of the stream. Not solved. This only happens on Samsung S4 and S5 phones w/KitKat 4.4.2 updates. At one point I received a message that it was not valid for progressive playback, so I tested a different live audio URL, which had no problems continuing playback.

The setlooping got the player to stay started, but just played the same audio over and over. As an incomplete fix, I added a mediaplayer reset, followed by a call to my playshow method in my onCompletionListener, which works to get the rest of the show, but it causes about a second of the show to be skipped each time. Anyone have any idea of what is going on with Samsung phones streaming live audio? Thanks.

lcs
  • 51
  • 1
  • 4
  • https://github.com/cozybit/aosp-frameworks-base/blob/master/include/media/mediaplayer.h – Robert Rowntree Jul 11 '14 at 17:21
  • Thank you, @RobertRowntree. The only msg I see with just a 7 is MEDIA_PLAYER_PLAYBACK_COMPLETE. Any suggestions as to why it would think it was complete after only a minute when it is live audio streaming? (The show is not over.) – lcs Jul 11 '14 at 17:35
  • besides looking thru 'enums' in the header file, you need to know more about the context or type of the message you are getting... msg=3 for what? an error... a status update ... a state change ... – Robert Rowntree Jul 11 '14 at 18:09
  • 1
    I believe my audio problem is solved, (but maybe not in the best way). After @RobertRowntree helped me find that msg=7 is MEDIA_PLAYER_PLAYBACK_COMPLETE, I reread about states at [Android Media Player](http://developer.android.com/reference/android/media/MediaPlayer.html), and added a setLooping(true) to my code. This keeps the MediaPlayer in the Start state until the user presses the stop button. No more audio stopping on its own. Thank you. – lcs Jul 11 '14 at 18:36
  • I have an app in the store that streams both live and pre-recorded audio with a service. The only special things I do are call `MediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC)` and have my service's implementation onStartCommand return START_NOT_STICKY to reduce the liklihood of having the process killed while in the background. Can you share the URL to your live source? It's entirely possible this is a server issue and I would be willing to take a look later tonight. – selbie Jul 15 '14 at 20:04
  • Sorry, but I can't share the URL as it is for my day job. I do have the setAudioStreamType(AudioManager.STREAM_MUSIC) and the START_NOT_STICKY, although I also experimented with START_STICKY. – lcs Jul 15 '14 at 20:09
  • Old question, but any solution? I'm having this problem today with an S5 with Android 6.0.1 ... the service isn't being killed, the mediaplayer just stops playing about 5-10 secs after the screen goes dark – ShadowGod Aug 07 '16 at 04:36
  • Still a problem as of September 2016 on a Samsung S5 with Android 6.0.1 – ShadowGod Sep 22 '16 at 09:57
  • Welcome to android development :/ ...even after writing my own custom player using the vitamio lib and countless hours of testing in the device lab some of these demons just can't be killed due to androids fragmentation issues. There's always going to be some OS version or new device that won't follow the rules or comply with your patches. – greaterKing Feb 07 '17 at 03:50

0 Answers0