summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaleen Jain <shaleen.jain95@gmail.com>2016-07-15 16:41:21 +0530
committerShaleen Jain <shaleen.jain95@gmail.com>2016-07-17 00:22:14 -0700
commit815e4d86dc19e623b32366b035d027a3ffa169fa (patch)
tree6c0e64c358035559aaf9e27c5f4ad8720a60095d
parent16c100d1a9709438ecdd7a08afa392b8fd75aad3 (diff)
downloadandroid_packages_apps_Eleven-815e4d86dc19e623b32366b035d027a3ffa169fa.tar.gz
android_packages_apps_Eleven-815e4d86dc19e623b32366b035d027a3ffa169fa.tar.bz2
android_packages_apps_Eleven-815e4d86dc19e623b32366b035d027a3ffa169fa.zip
handle media keys
This lets Eleven respond to physical media keys on some devices as well as when the volumn buttons are long pressed when the screen is off and the 'Playback control' preference is true in settings. Change-Id: Ide906efdf90a6f42f3fcb6c5386328301165cb7c
-rw-r--r--src/com/cyanogenmod/eleven/MusicPlaybackService.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/com/cyanogenmod/eleven/MusicPlaybackService.java b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
index 1f5660c..22e641d 100644
--- a/src/com/cyanogenmod/eleven/MusicPlaybackService.java
+++ b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
@@ -66,7 +66,6 @@ import com.cyanogenmod.eleven.provider.SongPlayCount;
import com.cyanogenmod.eleven.service.MusicPlaybackTrack;
import com.cyanogenmod.eleven.utils.BitmapWithColors;
import com.cyanogenmod.eleven.utils.Lists;
-import com.cyanogenmod.eleven.utils.PreferenceUtils;
import com.cyanogenmod.eleven.utils.ShakeDetector;
import com.cyanogenmod.eleven.utils.SrtManager;
@@ -705,6 +704,7 @@ public class MusicPlaybackService extends Service {
}
});
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
+ mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
}
/**
@@ -1488,8 +1488,16 @@ public class MusicPlaybackService extends Service {
? PlaybackState.STATE_PLAYING
: PlaybackState.STATE_PAUSED;
+ long playBackStateActions = PlaybackState.ACTION_PLAY |
+ PlaybackState.ACTION_PLAY_PAUSE |
+ PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
+ PlaybackState.ACTION_PAUSE |
+ PlaybackState.ACTION_SKIP_TO_NEXT |
+ PlaybackState.ACTION_SKIP_TO_PREVIOUS;
+
if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
mSession.setPlaybackState(new PlaybackState.Builder()
+ .setActions(playBackStateActions)
.setState(playState, position(), 1.0f).build());
} else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) {
Bitmap albumArt = getAlbumArt(false).getBitmap();
@@ -1517,6 +1525,7 @@ public class MusicPlaybackService extends Service {
.build());
mSession.setPlaybackState(new PlaybackState.Builder()
+ .setActions(playBackStateActions)
.setState(playState, position(), 1.0f).build());
}
}