summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorRenato Mangini <mangini@google.com>2014-11-21 03:31:12 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-21 03:31:12 +0000
commit333e5d21437fc1be67649a816673bd6638742199 (patch)
tree4597463f645cd10955a7cbc6bd4d4ca4088a1c92 /samples
parent565cafe77001fc15f66d9a45d3e3e4c799f9f9cf (diff)
parent5777a7ff7e96d3fcb6d6293fb15e5dac8a8e05f6 (diff)
am 5777a7ff: am 0d0f4d63: Update browseable for MediaBrowserService sample.
* commit '5777a7ff7e96d3fcb6d6293fb15e5dac8a8e05f6': Update browseable for MediaBrowserService sample.
Diffstat (limited to 'samples')
-rw-r--r--samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.pngbin3201 -> 0 bytes
-rw-r--r--samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.pngbin4058 -> 0 bytes
-rw-r--r--samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.pngbin3305 -> 4835 bytes
-rw-r--r--samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.pngbin4131 -> 3309 bytes
-rw-r--r--samples/browseable/MediaBrowserService/src/com.example.android.mediabrowserservice/MusicService.java21
5 files changed, 16 insertions, 5 deletions
diff --git a/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.png b/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.png
deleted file mode 100644
index e435d2a9f..000000000
--- a/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.png b/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.png
deleted file mode 100644
index 0c75bb6da..000000000
--- a/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png
index 836085b68..fb7afb0c9 100644
--- a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png
+++ b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png
Binary files differ
diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png
index 7cd6cfc52..6f7fc75e1 100644
--- a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png
+++ b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png
Binary files differ
diff --git a/samples/browseable/MediaBrowserService/src/com.example.android.mediabrowserservice/MusicService.java b/samples/browseable/MediaBrowserService/src/com.example.android.mediabrowserservice/MusicService.java
index 1c8744f00..b48242664 100644
--- a/samples/browseable/MediaBrowserService/src/com.example.android.mediabrowserservice/MusicService.java
+++ b/samples/browseable/MediaBrowserService/src/com.example.android.mediabrowserservice/MusicService.java
@@ -39,7 +39,6 @@ import android.os.PowerManager;
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 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe
@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 class MusicService extends MediaBrowserService implements OnPreparedListe
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 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe
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 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe
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 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe
@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 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe
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 class MusicService extends MediaBrowserService implements OnPreparedListe
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;