ensure the service continues to run in the event it takes a long time for the service to load the media to play, e.g.,
streaming over a slow network.
This commit is contained in:
parent
ab78c1d410
commit
a3389490bb
|
@ -1932,6 +1932,14 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
try {
|
try {
|
||||||
// Manage the started state of this service.
|
// Manage the started state of this service.
|
||||||
switch (state.getState()) {
|
switch (state.getState()) {
|
||||||
|
case PlaybackStateCompat.STATE_CONNECTING:
|
||||||
|
// move the service to started, aka, making it foreground
|
||||||
|
// upon STATE_CONNECTING, i.e., in preparing to play a media.
|
||||||
|
// This is done so that in case the preparation takes a long time, e.g.,
|
||||||
|
// streaming over a slow network,
|
||||||
|
// the service won't be killed by the system prematurely.
|
||||||
|
moveServiceToStartedState(state);
|
||||||
|
break;
|
||||||
case PlaybackStateCompat.STATE_PLAYING:
|
case PlaybackStateCompat.STATE_PLAYING:
|
||||||
moveServiceToStartedState(state);
|
moveServiceToStartedState(state);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue