Search in sources :

Example 6 with PlaybackInfo

use of android.media.session.MediaController.PlaybackInfo in project android_frameworks_base by DirtyUnicorns.

the class MediaSessions method onActiveSessionsUpdatedH.

protected void onActiveSessionsUpdatedH(List<MediaController> controllers) {
    if (D.BUG)
        Log.d(TAG, "onActiveSessionsUpdatedH n=" + controllers.size());
    final Set<Token> toRemove = new HashSet<Token>(mRecords.keySet());
    for (MediaController controller : controllers) {
        final Token token = controller.getSessionToken();
        final PlaybackInfo pi = controller.getPlaybackInfo();
        toRemove.remove(token);
        if (!mRecords.containsKey(token)) {
            final MediaControllerRecord r = new MediaControllerRecord(controller);
            r.name = getControllerName(controller);
            mRecords.put(token, r);
            controller.registerCallback(r, mHandler);
        }
        final MediaControllerRecord r = mRecords.get(token);
        final boolean remote = isRemote(pi);
        if (remote) {
            updateRemoteH(token, r.name, pi);
            r.sentRemote = true;
        }
    }
    for (Token t : toRemove) {
        final MediaControllerRecord r = mRecords.get(t);
        r.controller.unregisterCallback(r);
        mRecords.remove(t);
        if (D.BUG)
            Log.d(TAG, "Removing " + r.name + " sentRemote=" + r.sentRemote);
        if (r.sentRemote) {
            mCallbacks.onRemoteRemoved(t);
            r.sentRemote = false;
        }
    }
}
Also used : MediaController(android.media.session.MediaController) PlaybackInfo(android.media.session.MediaController.PlaybackInfo) Token(android.media.session.MediaSession.Token) HashSet(java.util.HashSet)

Example 7 with PlaybackInfo

use of android.media.session.MediaController.PlaybackInfo in project android_frameworks_base by DirtyUnicorns.

the class MediaSessions method dump.

private static void dump(int n, PrintWriter writer, MediaController c) {
    writer.println("  Controller " + n + ": " + c.getPackageName());
    final Bundle extras = c.getExtras();
    final long flags = c.getFlags();
    final MediaMetadata mm = c.getMetadata();
    final PlaybackInfo pi = c.getPlaybackInfo();
    final PlaybackState playbackState = c.getPlaybackState();
    final List<QueueItem> queue = c.getQueue();
    final CharSequence queueTitle = c.getQueueTitle();
    final int ratingType = c.getRatingType();
    final PendingIntent sessionActivity = c.getSessionActivity();
    writer.println("    PlaybackState: " + Util.playbackStateToString(playbackState));
    writer.println("    PlaybackInfo: " + Util.playbackInfoToString(pi));
    if (mm != null) {
        writer.println("  MediaMetadata.desc=" + mm.getDescription());
    }
    writer.println("    RatingType: " + ratingType);
    writer.println("    Flags: " + flags);
    if (extras != null) {
        writer.println("    Extras:");
        for (String key : extras.keySet()) {
            writer.println("      " + key + "=" + extras.get(key));
        }
    }
    if (queueTitle != null) {
        writer.println("    QueueTitle: " + queueTitle);
    }
    if (queue != null && !queue.isEmpty()) {
        writer.println("    Queue:");
        for (QueueItem qi : queue) {
            writer.println("      " + qi);
        }
    }
    if (pi != null) {
        writer.println("    sessionActivity: " + sessionActivity);
    }
}
Also used : Bundle(android.os.Bundle) PlaybackInfo(android.media.session.MediaController.PlaybackInfo) MediaMetadata(android.media.MediaMetadata) PlaybackState(android.media.session.PlaybackState) QueueItem(android.media.session.MediaSession.QueueItem) PendingIntent(android.app.PendingIntent)

Example 8 with PlaybackInfo

use of android.media.session.MediaController.PlaybackInfo in project android_frameworks_base by ResurrectionRemix.

the class MediaSessions method onActiveSessionsUpdatedH.

protected void onActiveSessionsUpdatedH(List<MediaController> controllers) {
    if (D.BUG)
        Log.d(TAG, "onActiveSessionsUpdatedH n=" + controllers.size());
    final Set<Token> toRemove = new HashSet<Token>(mRecords.keySet());
    for (MediaController controller : controllers) {
        final Token token = controller.getSessionToken();
        final PlaybackInfo pi = controller.getPlaybackInfo();
        toRemove.remove(token);
        if (!mRecords.containsKey(token)) {
            final MediaControllerRecord r = new MediaControllerRecord(controller);
            r.name = getControllerName(controller);
            mRecords.put(token, r);
            controller.registerCallback(r, mHandler);
        }
        final MediaControllerRecord r = mRecords.get(token);
        final boolean remote = isRemote(pi);
        if (remote) {
            updateRemoteH(token, r.name, pi);
            r.sentRemote = true;
        }
    }
    for (Token t : toRemove) {
        final MediaControllerRecord r = mRecords.get(t);
        r.controller.unregisterCallback(r);
        mRecords.remove(t);
        if (D.BUG)
            Log.d(TAG, "Removing " + r.name + " sentRemote=" + r.sentRemote);
        if (r.sentRemote) {
            mCallbacks.onRemoteRemoved(t);
            r.sentRemote = false;
        }
    }
}
Also used : MediaController(android.media.session.MediaController) PlaybackInfo(android.media.session.MediaController.PlaybackInfo) Token(android.media.session.MediaSession.Token) HashSet(java.util.HashSet)

Example 9 with PlaybackInfo

use of android.media.session.MediaController.PlaybackInfo in project android_frameworks_base by ResurrectionRemix.

the class MediaSessions method dump.

private static void dump(int n, PrintWriter writer, MediaController c) {
    writer.println("  Controller " + n + ": " + c.getPackageName());
    final Bundle extras = c.getExtras();
    final long flags = c.getFlags();
    final MediaMetadata mm = c.getMetadata();
    final PlaybackInfo pi = c.getPlaybackInfo();
    final PlaybackState playbackState = c.getPlaybackState();
    final List<QueueItem> queue = c.getQueue();
    final CharSequence queueTitle = c.getQueueTitle();
    final int ratingType = c.getRatingType();
    final PendingIntent sessionActivity = c.getSessionActivity();
    writer.println("    PlaybackState: " + Util.playbackStateToString(playbackState));
    writer.println("    PlaybackInfo: " + Util.playbackInfoToString(pi));
    if (mm != null) {
        writer.println("  MediaMetadata.desc=" + mm.getDescription());
    }
    writer.println("    RatingType: " + ratingType);
    writer.println("    Flags: " + flags);
    if (extras != null) {
        writer.println("    Extras:");
        for (String key : extras.keySet()) {
            writer.println("      " + key + "=" + extras.get(key));
        }
    }
    if (queueTitle != null) {
        writer.println("    QueueTitle: " + queueTitle);
    }
    if (queue != null && !queue.isEmpty()) {
        writer.println("    Queue:");
        for (QueueItem qi : queue) {
            writer.println("      " + qi);
        }
    }
    if (pi != null) {
        writer.println("    sessionActivity: " + sessionActivity);
    }
}
Also used : Bundle(android.os.Bundle) PlaybackInfo(android.media.session.MediaController.PlaybackInfo) MediaMetadata(android.media.MediaMetadata) PlaybackState(android.media.session.PlaybackState) QueueItem(android.media.session.MediaSession.QueueItem) PendingIntent(android.app.PendingIntent)

Example 10 with PlaybackInfo

use of android.media.session.MediaController.PlaybackInfo in project android_frameworks_base by crdroidandroid.

the class MediaSessions method onActiveSessionsUpdatedH.

protected void onActiveSessionsUpdatedH(List<MediaController> controllers) {
    if (D.BUG)
        Log.d(TAG, "onActiveSessionsUpdatedH n=" + controllers.size());
    final Set<Token> toRemove = new HashSet<Token>(mRecords.keySet());
    for (MediaController controller : controllers) {
        final Token token = controller.getSessionToken();
        final PlaybackInfo pi = controller.getPlaybackInfo();
        toRemove.remove(token);
        if (!mRecords.containsKey(token)) {
            final MediaControllerRecord r = new MediaControllerRecord(controller);
            r.name = getControllerName(controller);
            mRecords.put(token, r);
            controller.registerCallback(r, mHandler);
        }
        final MediaControllerRecord r = mRecords.get(token);
        final boolean remote = isRemote(pi);
        if (remote) {
            updateRemoteH(token, r.name, pi);
            r.sentRemote = true;
        }
    }
    for (Token t : toRemove) {
        final MediaControllerRecord r = mRecords.get(t);
        r.controller.unregisterCallback(r);
        mRecords.remove(t);
        if (D.BUG)
            Log.d(TAG, "Removing " + r.name + " sentRemote=" + r.sentRemote);
        if (r.sentRemote) {
            mCallbacks.onRemoteRemoved(t);
            r.sentRemote = false;
        }
    }
}
Also used : MediaController(android.media.session.MediaController) PlaybackInfo(android.media.session.MediaController.PlaybackInfo) Token(android.media.session.MediaSession.Token) HashSet(java.util.HashSet)

Aggregations

PlaybackInfo (android.media.session.MediaController.PlaybackInfo)10 PendingIntent (android.app.PendingIntent)5 MediaMetadata (android.media.MediaMetadata)5 MediaController (android.media.session.MediaController)5 QueueItem (android.media.session.MediaSession.QueueItem)5 Token (android.media.session.MediaSession.Token)5 PlaybackState (android.media.session.PlaybackState)5 Bundle (android.os.Bundle)5 HashSet (java.util.HashSet)5