Search in sources :

Example 1 with MediaSessionManager

use of android.media.session.MediaSessionManager in project android_frameworks_base by DirtyUnicorns.

the class MediaSessions method dumpMediaSessions.

public static void dumpMediaSessions(Context context) {
    final MediaSessionManager mgr = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
    try {
        final List<MediaController> controllers = mgr.getActiveSessions(null);
        final int N = controllers.size();
        if (D.BUG)
            Log.d(TAG, N + " controllers");
        for (int i = 0; i < N; i++) {
            final StringWriter sw = new StringWriter();
            final PrintWriter pw = new PrintWriter(sw, true);
            dump(i + 1, pw, controllers.get(i));
            if (D.BUG)
                Log.d(TAG, sw.toString());
        }
    } catch (SecurityException e) {
        Log.w(TAG, "Not allowed to get sessions", e);
    }
}
Also used : MediaController(android.media.session.MediaController) StringWriter(java.io.StringWriter) MediaSessionManager(android.media.session.MediaSessionManager) PrintWriter(java.io.PrintWriter)

Example 2 with MediaSessionManager

use of android.media.session.MediaSessionManager in project android_frameworks_base by ResurrectionRemix.

the class MediaSessions method dumpMediaSessions.

public static void dumpMediaSessions(Context context) {
    final MediaSessionManager mgr = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
    try {
        final List<MediaController> controllers = mgr.getActiveSessions(null);
        final int N = controllers.size();
        if (D.BUG)
            Log.d(TAG, N + " controllers");
        for (int i = 0; i < N; i++) {
            final StringWriter sw = new StringWriter();
            final PrintWriter pw = new PrintWriter(sw, true);
            dump(i + 1, pw, controllers.get(i));
            if (D.BUG)
                Log.d(TAG, sw.toString());
        }
    } catch (SecurityException e) {
        Log.w(TAG, "Not allowed to get sessions", e);
    }
}
Also used : MediaController(android.media.session.MediaController) StringWriter(java.io.StringWriter) MediaSessionManager(android.media.session.MediaSessionManager) PrintWriter(java.io.PrintWriter)

Example 3 with MediaSessionManager

use of android.media.session.MediaSessionManager in project android_frameworks_base by crdroidandroid.

the class MediaSessions method dumpMediaSessions.

public static void dumpMediaSessions(Context context) {
    final MediaSessionManager mgr = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
    try {
        final List<MediaController> controllers = mgr.getActiveSessions(null);
        final int N = controllers.size();
        if (D.BUG)
            Log.d(TAG, N + " controllers");
        for (int i = 0; i < N; i++) {
            final StringWriter sw = new StringWriter();
            final PrintWriter pw = new PrintWriter(sw, true);
            dump(i + 1, pw, controllers.get(i));
            if (D.BUG)
                Log.d(TAG, sw.toString());
        }
    } catch (SecurityException e) {
        Log.w(TAG, "Not allowed to get sessions", e);
    }
}
Also used : MediaController(android.media.session.MediaController) StringWriter(java.io.StringWriter) MediaSessionManager(android.media.session.MediaSessionManager) PrintWriter(java.io.PrintWriter)

Example 4 with MediaSessionManager

use of android.media.session.MediaSessionManager in project platform_frameworks_base by android.

the class MediaSessions method dumpMediaSessions.

public static void dumpMediaSessions(Context context) {
    final MediaSessionManager mgr = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
    try {
        final List<MediaController> controllers = mgr.getActiveSessions(null);
        final int N = controllers.size();
        if (D.BUG)
            Log.d(TAG, N + " controllers");
        for (int i = 0; i < N; i++) {
            final StringWriter sw = new StringWriter();
            final PrintWriter pw = new PrintWriter(sw, true);
            dump(i + 1, pw, controllers.get(i));
            if (D.BUG)
                Log.d(TAG, sw.toString());
        }
    } catch (SecurityException e) {
        Log.w(TAG, "Not allowed to get sessions", e);
    }
}
Also used : MediaController(android.media.session.MediaController) StringWriter(java.io.StringWriter) MediaSessionManager(android.media.session.MediaSessionManager) PrintWriter(java.io.PrintWriter)

Example 5 with MediaSessionManager

use of android.media.session.MediaSessionManager 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)

Aggregations

MediaSessionManager (android.media.session.MediaSessionManager)9 MediaController (android.media.session.MediaController)5 PrintWriter (java.io.PrintWriter)5 StringWriter (java.io.StringWriter)5 MediaSession (android.media.session.MediaSession)4