Android auto skip button (#4865)

This commit is contained in:
Tony Tam 2021-01-24 03:27:37 -08:00 committed by GitHub
parent a36d66bf35
commit c32239be0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -1240,7 +1240,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
capabilities = capabilities | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
}
UiModeManager uiModeManager = (UiModeManager) getApplicationContext().getSystemService(Context.UI_MODE_SERVICE);
UiModeManager uiModeManager = (UiModeManager) getApplicationContext()
.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
sessionState.addCustomAction(
new PlaybackStateCompat.CustomAction.Builder(
@ -1908,7 +1909,10 @@ public class PlaybackService extends MediaBrowserServiceCompat {
@Override
public void onSkipToNext() {
Log.d(TAG, "onSkipToNext()");
if (UserPreferences.shouldHardwareButtonSkip()) {
UiModeManager uiModeManager = (UiModeManager) getApplicationContext()
.getSystemService(Context.UI_MODE_SERVICE);
if (UserPreferences.shouldHardwareButtonSkip()
|| uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
mediaPlayer.skip();
} else {
seekDelta(UserPreferences.getFastForwardSecs() * 1000);