Handling play/pause button from different headsets

This commit is contained in:
alexandre patelli 2018-03-13 22:57:59 +01:00
parent 36457400e7
commit 24f2999669

View file

@ -591,7 +591,7 @@ public final class BackgroundPlayer extends Service {
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT);
} else if (keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS) {
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT);
} else if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) {
} else if (keycode == KeyEvent.KEYCODE_HEADSETHOOK || keycode == KeyEvent.KEYCODE_MEDIA_PAUSE || keycode == KeyEvent.KEYCODE_MEDIA_PLAY) {
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
} else if (keycode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_FAST_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT);