当前位置: 首页>>代码示例>>Java>>正文


Java MediaSession.setSessionActivity方法代码示例

本文整理汇总了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
    ));
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:21,代码来源:MediaSessionHelper.java

示例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);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:30,代码来源:MusicBrowserService.java

示例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());
}
 
开发者ID:ErNaveen,项目名称:UniversalMusicPlayer,代码行数:40,代码来源:MusicService.java

示例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());
}
 
开发者ID:SferaDev,项目名称:MusicFromChina,代码行数:41,代码来源:MusicService.java

示例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);
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:36,代码来源:RemoteControlClientLP.java

示例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());
}
 
开发者ID:GeorgeMe,项目名称:UniversalAndroidMusicPlayer,代码行数:41,代码来源:MusicService.java

示例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);
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:30,代码来源:MusicBrowserService.java

示例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);
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:53,代码来源:MusicService.java


注:本文中的android.media.session.MediaSession.setSessionActivity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。