Minor fixes to MediaBrowserService sample
- Removed night mode custom action icons, since now they are tinted with
appropriate colors for day or night;
- Changed custom action icons to make them appropriate for tinted display
(transparency mask);
- Fixed playback state control when changing music while paused
Change-Id: I11a53e876f056bccacb26dcfb98e7c459a923559
diff --git a/media/MediaBrowserService/Application/src/main/java/com/example/android/mediabrowserservice/MusicService.java b/media/MediaBrowserService/Application/src/main/java/com/example/android/mediabrowserservice/MusicService.java
index 1c8744f..b482426 100644
--- a/media/MediaBrowserService/Application/src/main/java/com/example/android/mediabrowserservice/MusicService.java
+++ b/media/MediaBrowserService/Application/src/main/java/com/example/android/mediabrowserservice/MusicService.java
@@ -39,7 +39,6 @@
import android.os.SystemClock;
import android.service.media.MediaBrowserService;
-import com.example.android.mediabrowserservice.PackageValidator;
import com.example.android.mediabrowserservice.model.MusicProvider;
import com.example.android.mediabrowserservice.utils.LogHelper;
import com.example.android.mediabrowserservice.utils.MediaIDHelper;
@@ -379,6 +378,11 @@
@Override
public void onSkipToQueueItem(long queueId) {
LogHelper.d(TAG, "OnSkipToQueueItem:" + queueId);
+
+ if (mState == PlaybackState.STATE_PAUSED) {
+ mState = PlaybackState.STATE_STOPPED;
+ }
+
if (mPlayingQueue != null && !mPlayingQueue.isEmpty()) {
// set the current index on queue from the music Id:
@@ -393,6 +397,10 @@
public void onPlayFromMediaId(String mediaId, Bundle extras) {
LogHelper.d(TAG, "playFromMediaId mediaId:", mediaId, " extras=", extras);
+ if (mState == PlaybackState.STATE_PAUSED) {
+ mState = PlaybackState.STATE_STOPPED;
+ }
+
// The mediaId used here is not the unique musicId. This one comes from the
// MediaBrowser, and is actually a "hierarchy-aware mediaID": a concatenation of
// the hierarchy in MediaBrowser and the actual unique musicID. This is necessary
@@ -406,6 +414,7 @@
if (mPlayingQueue != null && !mPlayingQueue.isEmpty()) {
String uniqueMusicID = MediaIDHelper.extractMusicIDFromMediaID(mediaId);
+
// set the current index on queue from the music Id:
mCurrentIndexOnQueue = QueueHelper.getMusicIndexOnQueue(
mPlayingQueue, uniqueMusicID);
@@ -435,7 +444,7 @@
mCurrentIndexOnQueue = 0;
}
if (QueueHelper.isIndexPlayable(mCurrentIndexOnQueue, mPlayingQueue)) {
- mState = PlaybackState.STATE_PLAYING;
+ mState = PlaybackState.STATE_STOPPED;
handlePlayRequest();
} else {
LogHelper.e(TAG, "skipToNext: cannot skip to next. next Index=" +
@@ -448,7 +457,6 @@
@Override
public void onSkipToPrevious() {
LogHelper.d(TAG, "skipToPrevious");
-
mCurrentIndexOnQueue--;
if (mPlayingQueue != null && mCurrentIndexOnQueue < 0) {
// This sample's behavior: skipping to previous when in first song restarts the
@@ -456,7 +464,7 @@
mCurrentIndexOnQueue = 0;
}
if (QueueHelper.isIndexPlayable(mCurrentIndexOnQueue, mPlayingQueue)) {
- mState = PlaybackState.STATE_PLAYING;
+ mState = PlaybackState.STATE_STOPPED;
handlePlayRequest();
} else {
LogHelper.e(TAG, "skipToPrevious: cannot skip to previous. previous Index=" +
@@ -486,12 +494,15 @@
public void onPlayFromSearch(String query, Bundle extras) {
LogHelper.d(TAG, "playFromSearch query=", query);
+ if (mState == PlaybackState.STATE_PAUSED) {
+ mState = PlaybackState.STATE_STOPPED;
+ }
+
mPlayingQueue = QueueHelper.getPlayingQueueFromSearch(query, mMusicProvider);
LogHelper.d(TAG, "playFromSearch playqueue.length=" + mPlayingQueue.size());
mSession.setQueue(mPlayingQueue);
if (mPlayingQueue != null && !mPlayingQueue.isEmpty()) {
-
// start playing from the beginning of the queue
mCurrentIndexOnQueue = 0;
diff --git a/media/MediaBrowserService/Application/src/main/res/drawable-night-xxhdpi/ic_star_off.png b/media/MediaBrowserService/Application/src/main/res/drawable-night-xxhdpi/ic_star_off.png
deleted file mode 100644
index e435d2a..0000000
--- a/media/MediaBrowserService/Application/src/main/res/drawable-night-xxhdpi/ic_star_off.png
+++ /dev/null
Binary files differ
diff --git a/media/MediaBrowserService/Application/src/main/res/drawable-night-xxhdpi/ic_star_on.png b/media/MediaBrowserService/Application/src/main/res/drawable-night-xxhdpi/ic_star_on.png
deleted file mode 100644
index 0c75bb6..0000000
--- a/media/MediaBrowserService/Application/src/main/res/drawable-night-xxhdpi/ic_star_on.png
+++ /dev/null
Binary files differ
diff --git a/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_off.png b/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_off.png
index 836085b..fb7afb0 100644
--- a/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_off.png
+++ b/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_off.png
Binary files differ
diff --git a/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_on.png b/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_on.png
index 7cd6cfc..6f7fc75 100644
--- a/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_on.png
+++ b/media/MediaBrowserService/Application/src/main/res/drawable-xxhdpi/ic_star_on.png
Binary files differ