use of android.media.session.MediaSession in project android_frameworks_base by crdroidandroid.
the class PlayerSession method createSession.
public void createSession() {
releaseSession();
MediaSessionManager man = (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE);
Log.d(TAG, "Creating session for package " + mContext.getBasePackageName());
mSession = new MediaSession(mContext, "OneMedia");
mSession.setCallback(mCallback);
mSession.setPlaybackState(mPlaybackState);
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
mSession.setActive(true);
updateMetadata();
}
use of android.media.session.MediaSession in project android_frameworks_base by crdroidandroid.
the class BrowserService method onCreate.
@Override
public void onCreate() {
super.onCreate();
mSession = new MediaSession(this, "com.example.android.musicservicedemo.BrowserService");
setSessionToken(mSession.getSessionToken());
}
use of android.media.session.MediaSession in project platform_frameworks_base by android.
the class PlayerSession method createSession.
public void createSession() {
releaseSession();
MediaSessionManager man = (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE);
Log.d(TAG, "Creating session for package " + mContext.getBasePackageName());
mSession = new MediaSession(mContext, "OneMedia");
mSession.setCallback(mCallback);
mSession.setPlaybackState(mPlaybackState);
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
mSession.setActive(true);
updateMetadata();
}
use of android.media.session.MediaSession in project robolectric by robolectric.
the class ShadowMediaSessionManagerTest method getActiveSessions_callsActiveSessionListenersWithProvidedHandler.
@Test
public void getActiveSessions_callsActiveSessionListenersWithProvidedHandler() {
MediaSession mediaSession = new MediaSession(context, "tag");
MediaController mediaController = new MediaController(context, mediaSession.getSessionToken());
final List<MediaController> changedMediaControllers = new ArrayList<>();
Shadows.shadowOf(mediaSessionManager).addOnActiveSessionsChangedListener(changedMediaControllers::addAll, null, null);
Shadows.shadowOf(mediaSessionManager).addController(mediaController);
assertThat(changedMediaControllers).containsExactly(mediaController);
}
use of android.media.session.MediaSession in project robolectric by robolectric.
the class ShadowMediaSessionManagerTest method getActiveSessions_returnsAddedControllers.
@Test
public void getActiveSessions_returnsAddedControllers() {
MediaSession mediaSession = new MediaSession(context, "tag");
MediaController mediaController = new MediaController(context, mediaSession.getSessionToken());
Shadows.shadowOf(mediaSessionManager).addController(mediaController);
List<MediaController> mediaControllers = mediaSessionManager.getActiveSessions(null);
assertThat(mediaControllers).containsExactly(mediaController);
}
Aggregations