Search in sources :

Example 1 with MediaDescription

use of android.media.MediaDescription in project android_frameworks_base by ResurrectionRemix.

the class QueueViewRow method setQueueItem.

public void setQueueItem(MediaSession.QueueItem queueItem) {
    setTag(queueItem);
    MediaDescription metadata = queueItem.getDescription();
    final Bitmap bitmap = metadata.getIconBitmap();
    mArt.setImageBitmap(bitmap);
    mArt.setVisibility(bitmap != null ? View.VISIBLE : View.GONE);
    mTitle.setText(metadata.getTitle());
    mSummary.setText(metadata.getSubtitle());
}
Also used : Bitmap(android.graphics.Bitmap) MediaDescription(android.media.MediaDescription)

Example 2 with MediaDescription

use of android.media.MediaDescription in project android_frameworks_base by ResurrectionRemix.

the class MediaSessionRecord method getShortMetadataString.

private String getShortMetadataString() {
    int fields = mMetadata == null ? 0 : mMetadata.size();
    MediaDescription description = mMetadata == null ? null : mMetadata.getDescription();
    return "size=" + fields + ", description=" + description;
}
Also used : MediaDescription(android.media.MediaDescription)

Example 3 with MediaDescription

use of android.media.MediaDescription in project android_frameworks_base by ResurrectionRemix.

the class NotificationHelper method updateNotification.

private void updateNotification() {
    if (mNoMan == null) {
        mNoMan = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
    }
    if (mPlaybackState == null) {
        mNoMan.cancel(NOTIFICATION_ID);
        return;
    }
    if (!mStarted) {
        mNoMan.cancel(NOTIFICATION_ID);
        return;
    }
    String status;
    final int state = mPlaybackState.getState();
    switch(state) {
        case PlaybackState.STATE_PLAYING:
            status = "PLAYING: ";
            break;
        case PlaybackState.STATE_PAUSED:
            status = "PAUSED: ";
            break;
        case PlaybackState.STATE_STOPPED:
            status = "STOPPED: ";
            break;
        case PlaybackState.STATE_ERROR:
            status = "ERROR: ";
            break;
        case PlaybackState.STATE_BUFFERING:
            status = "BUFFERING: ";
            break;
        case PlaybackState.STATE_NONE:
        default:
            status = "";
            break;
    }
    CharSequence title, text;
    Bitmap art;
    if (mMetadata == null) {
        title = status;
        text = "Empty metadata!";
        art = null;
    } else {
        MediaDescription description = mMetadata.getDescription();
        title = description.getTitle();
        text = description.getSubtitle();
        art = description.getIconBitmap();
    }
    String playPauseLabel = "";
    int playPauseIcon;
    if (state == PlaybackState.STATE_PLAYING) {
        playPauseLabel = "Pause";
        playPauseIcon = R.drawable.ic_pause;
    } else {
        playPauseLabel = "Play";
        playPauseIcon = R.drawable.ic_play_arrow;
    }
    final long pos = mPlaybackState.getPosition();
    final long end = mMetadata == null ? 0 : mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
    Notification notification = new Notification.Builder(mService).setSmallIcon(android.R.drawable.stat_notify_chat).setContentTitle(title).setContentText(text).setShowWhen(false).setContentInfo(DateUtils.formatElapsedTime(pos)).setProgress((int) end, (int) pos, false).setLargeIcon(art).addAction(R.drawable.ic_skip_previous, "Previous", mIntents.get(R.drawable.ic_skip_previous)).addAction(R.drawable.ic_fast_rewind, "Rewind", mIntents.get(R.drawable.ic_fast_rewind)).addAction(playPauseIcon, playPauseLabel, mIntents.get(playPauseIcon)).addAction(R.drawable.ic_fast_forward, "Fast Forward", mIntents.get(R.drawable.ic_fast_forward)).addAction(R.drawable.ic_skip_next, "Next", mIntents.get(R.drawable.ic_skip_next)).setStyle(new Notification.MediaStyle().setShowActionsInCompactView(2).setMediaSession(mSession.getSessionToken())).setColor(0xFFDB4437).build();
    mService.startForeground(NOTIFICATION_ID, notification);
}
Also used : Bitmap(android.graphics.Bitmap) MediaDescription(android.media.MediaDescription) Notification(android.app.Notification)

Example 4 with MediaDescription

use of android.media.MediaDescription in project android_frameworks_base by DirtyUnicorns.

the class NotificationHelper method updateNotification.

private void updateNotification() {
    if (mNoMan == null) {
        mNoMan = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
    }
    if (mPlaybackState == null) {
        mNoMan.cancel(NOTIFICATION_ID);
        return;
    }
    if (!mStarted) {
        mNoMan.cancel(NOTIFICATION_ID);
        return;
    }
    String status;
    final int state = mPlaybackState.getState();
    switch(state) {
        case PlaybackState.STATE_PLAYING:
            status = "PLAYING: ";
            break;
        case PlaybackState.STATE_PAUSED:
            status = "PAUSED: ";
            break;
        case PlaybackState.STATE_STOPPED:
            status = "STOPPED: ";
            break;
        case PlaybackState.STATE_ERROR:
            status = "ERROR: ";
            break;
        case PlaybackState.STATE_BUFFERING:
            status = "BUFFERING: ";
            break;
        case PlaybackState.STATE_NONE:
        default:
            status = "";
            break;
    }
    CharSequence title, text;
    Bitmap art;
    if (mMetadata == null) {
        title = status;
        text = "Empty metadata!";
        art = null;
    } else {
        MediaDescription description = mMetadata.getDescription();
        title = description.getTitle();
        text = description.getSubtitle();
        art = description.getIconBitmap();
    }
    String playPauseLabel = "";
    int playPauseIcon;
    if (state == PlaybackState.STATE_PLAYING) {
        playPauseLabel = "Pause";
        playPauseIcon = R.drawable.ic_pause;
    } else {
        playPauseLabel = "Play";
        playPauseIcon = R.drawable.ic_play_arrow;
    }
    final long pos = mPlaybackState.getPosition();
    final long end = mMetadata == null ? 0 : mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
    Notification notification = new Notification.Builder(mService).setSmallIcon(android.R.drawable.stat_notify_chat).setContentTitle(title).setContentText(text).setShowWhen(false).setContentInfo(DateUtils.formatElapsedTime(pos)).setProgress((int) end, (int) pos, false).setLargeIcon(art).addAction(R.drawable.ic_skip_previous, "Previous", mIntents.get(R.drawable.ic_skip_previous)).addAction(R.drawable.ic_fast_rewind, "Rewind", mIntents.get(R.drawable.ic_fast_rewind)).addAction(playPauseIcon, playPauseLabel, mIntents.get(playPauseIcon)).addAction(R.drawable.ic_fast_forward, "Fast Forward", mIntents.get(R.drawable.ic_fast_forward)).addAction(R.drawable.ic_skip_next, "Next", mIntents.get(R.drawable.ic_skip_next)).setStyle(new Notification.MediaStyle().setShowActionsInCompactView(2).setMediaSession(mSession.getSessionToken())).setColor(0xFFDB4437).build();
    mService.startForeground(NOTIFICATION_ID, notification);
}
Also used : Bitmap(android.graphics.Bitmap) MediaDescription(android.media.MediaDescription) Notification(android.app.Notification)

Example 5 with MediaDescription

use of android.media.MediaDescription in project android_frameworks_base by AOSPA.

the class MediaSessionRecord method getShortMetadataString.

private String getShortMetadataString() {
    int fields = mMetadata == null ? 0 : mMetadata.size();
    MediaDescription description = mMetadata == null ? null : mMetadata.getDescription();
    return "size=" + fields + ", description=" + description;
}
Also used : MediaDescription(android.media.MediaDescription)

Aggregations

MediaDescription (android.media.MediaDescription)11 Bitmap (android.graphics.Bitmap)6 Notification (android.app.Notification)4