本文整理汇总了Java中android.media.session.MediaSession.setSessionActivity方法的典型用法代码示例。如果您正苦于以下问题:Java MediaSession.setSessionActivity方法的具体用法?Java MediaSession.setSessionActivity怎么用?Java MediaSession.setSessionActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.session.MediaSession
的用法示例。
在下文中一共展示了MediaSession.setSessionActivity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
void setup() {
mHandlerThread = new HandlerThread(getClass().getName(), Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
mMediaSession = new MediaSession(mService, mService.getClass().getName());
mMediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS|MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mMediaSession.setCallback(new Callback(), new Handler(mHandlerThread.getLooper()));
mMediaSession.setMediaButtonReceiver(PendingIntent.getBroadcast(
mService,
1,
new Intent(mService, MediaButtonIntentReceiver.class),
PendingIntent.FLAG_UPDATE_CURRENT
));
mMediaSession.setSessionActivity(PendingIntent.getActivity(
mService,
2,
NavUtils.makeLauncherIntent(mService),
PendingIntent.FLAG_UPDATE_CURRENT
));
}
示例2: onCreate
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
ApplicationLoader.postInitApplication();
lastSelectedDialog = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getInt("auto_lastSelectedDialog", 0);
mediaSession = new MediaSession(this, "MusicService");
setSessionToken(mediaSession.getSessionToken());
mediaSession.setCallback(new MediaSessionCallback());
mediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
Context context = getApplicationContext();
Intent intent = new Intent(context, LaunchActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mediaSession.setSessionActivity(pi);
Bundle extras = new Bundle();
extras.putBoolean(SLOT_RESERVATION_QUEUE, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_PREV, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_NEXT, true);
mediaSession.setExtras(extras);
updatePlaybackState(null);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioPlayStateChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
}
示例3: onCreate
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = ((UAMPApplication)getApplication()).getCastManager(getApplicationContext());
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
}
示例4: onCreate
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
}
示例5: register
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void register(Context context, ComponentName mediaButtonReceiverComponent) {
downloadService = (DownloadService) context;
mediaSession = new MediaSession(downloadService, "DSub MediaSession");
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);
mediaSession.setMediaButtonReceiver(mediaPendingIntent);
Intent activityIntent = new Intent(context, SubsonicFragmentActivity.class);
activityIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent activityPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);
mediaSession.setSessionActivity(activityPendingIntent);
mediaSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
mediaSession.setCallback(new EventCallback());
AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder();
audioAttributesBuilder.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
mediaSession.setPlaybackToLocal(audioAttributesBuilder.build());
mediaSession.setActive(true);
Bundle sessionExtras = new Bundle();
sessionExtras.putBoolean(WEAR_BACKGROUND_THEME, true);
sessionExtras.putBoolean(WEAR_RESERVE_SKIP_TO_PREVIOUS, true);
sessionExtras.putBoolean(WEAR_RESERVE_SKIP_TO_NEXT, true);
sessionExtras.putBoolean(AUTO_RESERVE_SKIP_TO_PREVIOUS, true);
sessionExtras.putBoolean(AUTO_RESERVE_SKIP_TO_NEXT, true);
mediaSession.setExtras(sessionExtras);
imageLoader = SubsonicActivity.getStaticImageLoader(context);
}
示例6: onCreate
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
}
示例7: onCreate
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
ApplicationLoader.postInitApplication();
lastSelectedDialog = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getInt("auto_lastSelectedDialog", 0);
mediaSession = new MediaSession(this, "MusicService");
setSessionToken(mediaSession.getSessionToken());
mediaSession.setCallback(new MediaSessionCallback());
mediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
Context context = getApplicationContext();
Intent intent = new Intent(context, LaunchActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mediaSession.setSessionActivity(pi);
Bundle extras = new Bundle();
extras.putBoolean(SLOT_RESERVATION_QUEUE, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_PREV, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_NEXT, true);
mediaSession.setExtras(extras);
updatePlaybackState(null);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagePlayingDidStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagePlayingDidReset);
}
示例8: onCreate
import android.media.session.MediaSession; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
IntentFilter filter = new IntentFilter(CarHelper.ACTION_MEDIA_STATUS);
mCarConnectionReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String connectionEvent = intent.getStringExtra(CarHelper.MEDIA_CONNECTION_STATUS);
mIsConnectedToCar = CarHelper.MEDIA_CONNECTED.equals(connectionEvent);
LogHelper.i(TAG, "Connection event to Android Auto: ", connectionEvent,
" isConnectedToCar=", mIsConnectedToCar);
}
};
registerReceiver(mCarConnectionReceiver, filter);
}