private void setUpMediaSession() { mSession = new MediaSession(this, "remusic"); mSession.setCallback(new MediaSession.Callback() { @Override
@Test public void mediaSessionCompat_creation() throws Exception { // Should not result in an exception. new MediaSession(ApplicationProvider.getApplicationContext(), "test"); } }
@Override public void onCreate() { super.onCreate(); sInstance = this; mContext = this; mSession = new MediaSession(this, "WearBrowserService"); setSessionToken(mSession.getSessionToken()); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); }
final MediaSession mediaSession = new MediaSession(this, "debug tag");
mSession = new MediaSession(this, "Service"); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mSession = new MediaSession(this, "MusicService"); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
public static Object createSession(Context context, String tag) { return new MediaSession(context, tag); }
if (mAudioManager == null) { mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (mRemoteControlClient == null) { Log.d("init()", "API " + Build.VERSION.SDK_INT + " lower then " + Build.VERSION_CODES.LOLLIPOP); Log.d("init()", "Using RemoteControlClient API."); mRemoteControlClient = new RemoteControlClient(PendingIntent.getBroadcast(this, 0, new Intent(Intent.ACTION_MEDIA_BUTTON), 0)); mAudioManager.registerRemoteControlClient(mRemoteControlClient); } } else { if (mMediaSession == null) { Log.d("init()", "API " + Build.VERSION.SDK_INT + " greater or equals " + Build.VERSION_CODES.LOLLIPOP); Log.d("init()", "Using MediaSession API."); mMediaSession = new MediaSession(this, "PlayerServiceMediaSession"); mMediaSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); mMediaSession.setActive(true); } }
public void checkForMediaSession() { MediaSessionManager manager = (MediaSessionManager) this.mContext.getApplicationContext().getSystemService("media_session"); if (manager != null) { if (!this.mIsTestRunning) { new MediaSession(this.mContext.getApplicationContext(), "NowPlayCardListener").release(); } onActiveSessionsChanged(manager.getActiveSessions(null)); } } }
return; mMediaSession = new MediaSession(mContext, "Vanilla Music");
@Override public void onCreate() { super.onCreate(); sInstance = this; mContext = this; mSession = new MediaSession(this, "WearBrowserService"); setSessionToken(mSession.getSessionToken()); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); }
/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.playback_controls); loadViews(); setupCallbacks(); mSession = new MediaSession(this, "LeanbackSampleApp"); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); mSession.setActive(true); }
@Override public void onCreate() { super.onCreate(); sInstance = this; mContext = this; mSession = new MediaSession(this, "WearBrowserService"); setSessionToken(mSession.getSessionToken()); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); }
mSession = new MediaSession(this, "VanillaMediaBrowserService"); setSessionToken(mSession.getSessionToken()); mSession.setCallback(new MediaSessionCallback());
mMediaSession.release(); mMediaSession = new MediaSession(getContext(), MEDIA_SESSION_TAG); mMediaSession.setCallback(new MediaSession.Callback() { @Override