Notification CreateNotification() { LogHelper.Debug(Tag, "updateNotificationMetadata. mMetadata=" + metadata); if (metadata == null || playbackState == null) { return(null); } var notificationBuilder = new Notification.Builder(service); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((playbackState.Actions & PlaybackState.ActionSkipToPrevious) != 0) { notificationBuilder.AddAction(Resource.Drawable.ic_skip_previous_white_24dp, service.GetString(Resource.String.label_previous), previousIntent); playPauseButtonPosition = 1; } AddPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((playbackState.Actions & PlaybackState.ActionSkipToNext) != 0) { notificationBuilder.AddAction(Resource.Drawable.ic_skip_next_white_24dp, service.GetString(Resource.String.label_next), nextIntent); } MediaDescription description = metadata.Description; var fetchArtUrl = string.Empty; Bitmap art = null; if (description.IconUri != null) { String artUrl = description.IconUri.ToString(); art = AlbumArtCache.Instance.GetBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; art = BitmapFactory.DecodeResource(service.Resources, Resource.Drawable.ic_default_art); } } notificationBuilder .SetStyle(new Notification.MediaStyle() .SetShowActionsInCompactView( new [] { playPauseButtonPosition }) // show only play/pause in compact view .SetMediaSession(sessionToken)) .SetColor(notificationColor) .SetSmallIcon(Resource.Drawable.ic_notification) .SetVisibility(NotificationVisibility.Public) .SetUsesChronometer(true) .SetContentIntent(CreateContentIntent()) .SetContentTitle(description.Title) .SetContentText(description.Subtitle) .SetLargeIcon(art); SetNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { FetchBitmapFromURL(fetchArtUrl, notificationBuilder); } return(notificationBuilder.Build()); }
public void OnPrepared(MediaPlayer mp) { LogHelper.Debug(Tag, "onPrepared from MediaPlayer"); ConfigMediaPlayerState(); }