Search in sources :

Example 11 with MediaSession

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();
}
Also used : MediaSession(android.media.session.MediaSession) MediaSessionManager(android.media.session.MediaSessionManager)

Example 12 with MediaSession

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());
}
Also used : MediaSession(android.media.session.MediaSession)

Example 13 with MediaSession

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();
}
Also used : MediaSession(android.media.session.MediaSession) MediaSessionManager(android.media.session.MediaSessionManager)

Example 14 with MediaSession

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);
}
Also used : MediaController(android.media.session.MediaController) MediaSession(android.media.session.MediaSession) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with MediaSession

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);
}
Also used : MediaController(android.media.session.MediaController) MediaSession(android.media.session.MediaSession) Test(org.junit.Test)

Aggregations

MediaSession (android.media.session.MediaSession)16 MediaController (android.media.session.MediaController)4 MediaSessionManager (android.media.session.MediaSessionManager)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 MediaDescription (android.media.MediaDescription)1 MediaMetadata (android.media.MediaMetadata)1 MediaPlayer (android.media.MediaPlayer)1 Rating (android.media.Rating)1 PlaybackState (android.media.session.PlaybackState)1 Handler (android.os.Handler)1 NotificationCompat (android.support.v7.app.NotificationCompat)1 Palette (android.support.v7.graphics.Palette)1 MainActivity (com.freedom.lauzy.ticktockmusic.ui.activity.MainActivity)1 PlayerFragment (com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment)1