Issues with MediaPlayer Streaming on Android 4.4 (API 19)

My application is having problems streaming MediaPlayer, particularly on Nexus 5. I'm not sure if this is a Nexus 5 or API 19 issue causing the problem. Basically my MediaPlayer is prepared, and I call MediaPlayer.start() , but MediaPlayer does not start streaming.

This happens randomly and only on my Nexus 5 device. When this happens, if I try to find MediaPlayer, it will start playing. Does anyone else experience this?

UPDATE: I filed an error on Android: https://code.google.com/p/android/issues/detail?id=62304

+6
source share
2 answers

Not sure if this is related, I had a similar problem with local file playback, only 4.4 times and not playable in 4.3. This only happens when I want to play a new song that reuses the existing MediaPlayer.

Solution: I had to call stop (); to reset (); and setDataSource ():

  stop(); reset(); try { setDataSource(context, uri); prepareAsync(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } 
+1
source

workaround: in onprepare before running try this code:

 if (mSeekWhenPrepared != 0) { seekTo(mSeekWhenPrepared); } else {seekTo(0);} 
0
source

Source: https://habr.com/ru/post/957865/


All Articles