set pending activity intent on mediasession
This commit is contained in:
parent
247fa77f9d
commit
2f235fc46e
|
@ -29,6 +29,7 @@ import android.support.v4.media.MediaDescriptionCompat;
|
||||||
import android.support.v4.media.MediaMetadataCompat;
|
import android.support.v4.media.MediaMetadataCompat;
|
||||||
import android.support.v4.media.session.MediaSessionCompat;
|
import android.support.v4.media.session.MediaSessionCompat;
|
||||||
import android.support.v4.media.session.PlaybackStateCompat;
|
import android.support.v4.media.session.PlaybackStateCompat;
|
||||||
|
import android.support.v4.view.InputDeviceCompat;
|
||||||
import android.support.v7.app.NotificationCompat;
|
import android.support.v7.app.NotificationCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -41,8 +42,8 @@ import android.widget.Toast;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.ClientConfig;
|
import de.danoeh.antennapod.core.ClientConfig;
|
||||||
import de.danoeh.antennapod.core.R;
|
import de.danoeh.antennapod.core.R;
|
||||||
|
@ -300,7 +301,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
|
|
||||||
List<MediaSessionCompat.QueueItem> queueItems = new ArrayList<>();
|
List<MediaSessionCompat.QueueItem> queueItems = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
for (FeedItem feedItem: taskManager.getQueue()) {
|
for (FeedItem feedItem : taskManager.getQueue()) {
|
||||||
queueItems.add(new MediaSessionCompat.QueueItem(feedItem.getMedia().getMediaItem().getDescription(), feedItem.getId()));
|
queueItems.add(new MediaSessionCompat.QueueItem(feedItem.getMedia().getMediaItem().getDescription(), feedItem.getId()));
|
||||||
}
|
}
|
||||||
mediaSession.setQueue(queueItems);
|
mediaSession.setQueue(queueItems);
|
||||||
|
@ -343,7 +344,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BrowserRoot onGetRoot(String clientPackageName, int clientUid, Bundle rootHints) {
|
public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, Bundle rootHints) {
|
||||||
Log.d(TAG, "OnGetRoot: clientPackageName=" + clientPackageName +
|
Log.d(TAG, "OnGetRoot: clientPackageName=" + clientPackageName +
|
||||||
"; clientUid=" + clientUid + " ; rootHints=" + rootHints);
|
"; clientUid=" + clientUid + " ; rootHints=" + rootHints);
|
||||||
return new BrowserRoot(
|
return new BrowserRoot(
|
||||||
|
@ -361,10 +362,10 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadChildren(String parentId,
|
public void onLoadChildren(@NonNull String parentId,
|
||||||
Result<List<MediaBrowserCompat.MediaItem>> result) {
|
@NonNull Result<List<MediaBrowserCompat.MediaItem>> result) {
|
||||||
Log.d(TAG, "OnLoadChildren: parentMediaId=" + parentId);
|
Log.d(TAG, "OnLoadChildren: parentMediaId=" + parentId);
|
||||||
List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<MediaBrowserCompat.MediaItem>();
|
List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>();
|
||||||
if (parentId.equals(getResources().getString(R.string.app_name))) {
|
if (parentId.equals(getResources().getString(R.string.app_name))) {
|
||||||
// Root List
|
// Root List
|
||||||
mediaItems.add(createBrowsableMediaItemForRoot());
|
mediaItems.add(createBrowsableMediaItemForRoot());
|
||||||
|
@ -409,7 +410,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
if (keycode != -1) {
|
if (keycode != -1) {
|
||||||
Log.d(TAG, "Received media button event");
|
Log.d(TAG, "Received media button event");
|
||||||
handleKeycode(keycode, intent.getIntExtra(MediaButtonReceiver.EXTRA_SOURCE,
|
handleKeycode(keycode, intent.getIntExtra(MediaButtonReceiver.EXTRA_SOURCE,
|
||||||
InputDevice.SOURCE_CLASS_NONE));
|
InputDeviceCompat.SOURCE_CLASS_NONE));
|
||||||
} else if (!flavorHelper.castDisconnect(castDisconnect)) {
|
} else if (!flavorHelper.castDisconnect(castDisconnect)) {
|
||||||
started = true;
|
started = true;
|
||||||
boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM,
|
boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM,
|
||||||
|
@ -1024,7 +1025,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Thread.currentThread().isInterrupted() && started) {
|
if (!Thread.currentThread().isInterrupted() && started) {
|
||||||
//TODO mediaSession.setSessionActivity();
|
mediaSession.setSessionActivity(PendingIntent.getActivity(this, 0,
|
||||||
|
PlaybackService.getPlayerActivityIntent(this),
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT));
|
||||||
mediaSession.setMetadata(builder.build());
|
mediaSession.setMetadata(builder.build());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1171,8 +1174,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
.setShowActionsInCompactView(compactActionList.toArray())
|
.setShowActionsInCompactView(compactActionList.toArray())
|
||||||
.setShowCancelButton(true)
|
.setShowCancelButton(true)
|
||||||
.setCancelButtonIntent(stopButtonPendingIntent))
|
.setCancelButtonIntent(stopButtonPendingIntent))
|
||||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
.setColor(Notification.COLOR_DEFAULT);
|
.setColor(NotificationCompat.COLOR_DEFAULT);
|
||||||
|
|
||||||
notification = notificationBuilder.build();
|
notification = notificationBuilder.build();
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,8 @@ public class PlaybackServiceFlavorHelper {
|
||||||
boolean castDisconnect(boolean castDisconnect) {
|
boolean castDisconnect(boolean castDisconnect) {
|
||||||
if (castDisconnect) {
|
if (castDisconnect) {
|
||||||
castManager.disconnect();
|
castManager.disconnect();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return castDisconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean onMediaPlayerInfo(Context context, int code, @StringRes int resourceId) {
|
boolean onMediaPlayerInfo(Context context, int code, @StringRes int resourceId) {
|
||||||
|
|
Loading…
Reference in New Issue