use of android.media.MediaDescription in project android_frameworks_base by crdroidandroid.
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);
}
use of android.media.MediaDescription in project platform_frameworks_base by android.
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);
}
use of android.media.MediaDescription in project platform_frameworks_base by android.
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;
}
use of android.media.MediaDescription in project android_frameworks_base by DirtyUnicorns.
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;
}
use of android.media.MediaDescription in project android_frameworks_base by crdroidandroid.
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;
}
Aggregations