You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
public class MediaPlaybackService extends MediaBrowserServiceCompat {
private MediaSessionCompat mMediaSession; @OverRide
public void onCreate() {
super.onCreate();
// Create your MediaSessionCompat.
// You should already be doing this
mMediaSession = new MediaSessionCompat(this,
MediaPlaybackService.class.getSimpleName());
// Make sure to configure your MediaSessionCompat as per
// https://www.youtube.com/watch?v=FBC1FgWe5X4
setSessionToken(mMediaSession.getSessionToken());
} @OverRide
public BrowserRoot onGetRoot(@nonnull String clientPackageName,
int clientUid, Bundle rootHints) {
// Returning null == no one can connect
// so we’ll return something
return new BrowserRoot(
getString(R.string.app_name), // Name visible in Android Auto
null); // Bundle of optional extras
} @OverRide
public void onLoadChildren(String parentId,
Result<List<MediaBrowserCompat.MediaItem>> result) {
// I promise we’ll get to browsing
result.sendResult(null);
}
}
2582ad5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class MediaPlaybackService extends MediaBrowserServiceCompat {
private MediaSessionCompat mMediaSession;
@OverRide
public void onCreate() {
super.onCreate();
// Create your MediaSessionCompat.
// You should already be doing this
mMediaSession = new MediaSessionCompat(this,
MediaPlaybackService.class.getSimpleName());
// Make sure to configure your MediaSessionCompat as per
// https://www.youtube.com/watch?v=FBC1FgWe5X4
setSessionToken(mMediaSession.getSessionToken());
}
@OverRide
public BrowserRoot onGetRoot(@nonnull String clientPackageName,
int clientUid, Bundle rootHints) {
// Returning null == no one can connect
// so we’ll return something
return new BrowserRoot(
getString(R.string.app_name), // Name visible in Android Auto
null); // Bundle of optional extras
}
@OverRide
public void onLoadChildren(String parentId,
Result<List<MediaBrowserCompat.MediaItem>> result) {
// I promise we’ll get to browsing
result.sendResult(null);
}
}