Made sure PlaybackService only reacts to transient audio focus loss if

it's in the PLAYING state
This commit is contained in:
daniel oeh 2012-09-14 14:34:46 +02:00
parent 71f948cafa
commit 9f25077b94

View File

@ -276,17 +276,21 @@ public class PlaybackService extends Service {
}
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
if (AppConfig.DEBUG)
Log.d(TAG, "Lost audio focus temporarily. Ducking...");
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_LOWER, 0);
pausedBecauseOfTransientAudiofocusLoss = true;
if (status == PlayerStatus.PLAYING) {
if (AppConfig.DEBUG)
Log.d(TAG, "Lost audio focus temporarily. Ducking...");
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_LOWER, 0);
pausedBecauseOfTransientAudiofocusLoss = true;
}
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
if (AppConfig.DEBUG)
Log.d(TAG, "Lost audio focus temporarily. Pausing...");
pause(false);
pausedBecauseOfTransientAudiofocusLoss = true;
if (status == PlayerStatus.PLAYING) {
if (AppConfig.DEBUG)
Log.d(TAG, "Lost audio focus temporarily. Pausing...");
pause(false);
pausedBecauseOfTransientAudiofocusLoss = true;
}
}
}
};
@ -722,9 +726,11 @@ public class PlaybackService extends Service {
Bitmap icon = BitmapFactory.decodeResource(null,
R.drawable.ic_stat_antenna);
notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.playbackservice_notification_title))
.setContentText(getString(R.string.playbackservice_notification_content)).setOngoing(true)
.setContentIntent(pIntent).setLargeIcon(icon)
.setContentTitle(
getString(R.string.playbackservice_notification_title))
.setContentText(
getString(R.string.playbackservice_notification_content))
.setOngoing(true).setContentIntent(pIntent).setLargeIcon(icon)
.setSmallIcon(R.drawable.ic_stat_antenna);
startForeground(NOTIFICATION_ID, notificationBuilder.getNotification());