summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/service/playback/PlaybackService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/danoeh/antennapod/service/playback/PlaybackService.java')
-rw-r--r--src/de/danoeh/antennapod/service/playback/PlaybackService.java38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackService.java b/src/de/danoeh/antennapod/service/playback/PlaybackService.java
index 163a57ed2..60e39275a 100644
--- a/src/de/danoeh/antennapod/service/playback/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/playback/PlaybackService.java
@@ -323,6 +323,12 @@ public class PlaybackService extends Service {
case KeyEvent.KEYCODE_MEDIA_REWIND:
mediaPlayer.seekDelta(-UserPreferences.getSeekDeltaMs());
break;
+ case KeyEvent.KEYCODE_MEDIA_STOP:
+ if (status == PlayerStatus.PLAYING) {
+ mediaPlayer.pause(true, true);
+ }
+ stopForeground(true); // gets rid of persistent notification
+ break;
default:
if (info.playable != null && info.playerStatus == PlayerStatus.PLAYING) { // only notify the user about an unknown key event if it is actually doing something
String message = String.format(getResources().getString(R.string.unknown_media_key), keycode);
@@ -396,7 +402,7 @@ public class PlaybackService extends Service {
taskManager.cancelPositionSaver();
saveCurrentPosition(false, 0);
taskManager.cancelWidgetUpdater();
- stopForeground(true);
+// stopForeground(true); // do not remove notification on pause
break;
case STOPPED:
@@ -703,7 +709,7 @@ public class PlaybackService extends Service {
String contentTitle = info.playable.getEpisodeTitle();
Notification notification = null;
if (android.os.Build.VERSION.SDK_INT >= 16) {
- Intent pauseButtonIntent = new Intent(
+ Intent pauseButtonIntent = new Intent( // pause button intent
PlaybackService.this, PlaybackService.class);
pauseButtonIntent.putExtra(
MediaButtonReceiver.EXTRA_KEYCODE,
@@ -712,6 +718,24 @@ public class PlaybackService extends Service {
.getService(PlaybackService.this, 0,
pauseButtonIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent playButtonIntent = new Intent( // play button intent
+ PlaybackService.this, PlaybackService.class);
+ playButtonIntent.putExtra(
+ MediaButtonReceiver.EXTRA_KEYCODE,
+ KeyEvent.KEYCODE_MEDIA_PLAY);
+ PendingIntent playButtonPendingIntent = PendingIntent
+ .getService(PlaybackService.this, 1,
+ playButtonIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent stopButtonIntent = new Intent( // stop button intent
+ PlaybackService.this, PlaybackService.class);
+ stopButtonIntent.putExtra(
+ MediaButtonReceiver.EXTRA_KEYCODE,
+ KeyEvent.KEYCODE_MEDIA_STOP);
+ PendingIntent stopButtonPendingIntent = PendingIntent
+ .getService(PlaybackService.this, 2,
+ stopButtonIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder notificationBuilder = new Notification.Builder(
PlaybackService.this)
.setContentTitle(contentTitle)
@@ -720,9 +744,15 @@ public class PlaybackService extends Service {
.setContentIntent(pIntent)
.setLargeIcon(icon)
.setSmallIcon(R.drawable.ic_stat_antenna)
- .addAction(android.R.drawable.ic_media_pause,
+ .addAction(android.R.drawable.ic_media_pause, //pause action
getString(R.string.pause_label),
- pauseButtonPendingIntent);
+ pauseButtonPendingIntent)
+ .addAction(android.R.drawable.ic_media_play, //play action
+ getString(R.string.play_label),
+ playButtonPendingIntent)
+ .addAction(android.R.drawable.ic_media_stop, // stop action
+ getString(R.string.stop_label),
+ stopButtonPendingIntent);
notification = notificationBuilder.build();
} else {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(