Exemple #1
0
        protected virtual void PrepareNotificationManager()
        {
            MediaDescriptionAdapter   = new MediaDescriptionAdapter(SessionActivityPendingIntent);
            PlayerNotificationManager = Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.CreateWithNotificationChannel(
                this,
                ChannelId,
                Resource.String.exo_download_notification_channel_name,
                ForegroundNotificationId,
                MediaDescriptionAdapter);

            //Needed for enabling the notification as a mediabrowser.
            NotificationListener = new NotificationListener();
            NotificationListener.OnNotificationStartedImpl = (notificationId, notification) =>
            {
                StartForeground(notificationId, notification);
            };
            NotificationListener.OnNotificationCancelledImpl = (notificationId) =>
            {
                StopSelf();
            };

            PlayerNotificationManager.SetNotificationListener(NotificationListener);
            PlayerNotificationManager.SetMediaSessionToken(SessionToken);
            PlayerNotificationManager.SetPlayer(MediaManager.NativeMediaPlayer.Player);

            //TODO: When only 1 in queue disable navigation
            //PlayerNotificationManager.SetUseNavigationActions(false);
            //PlayerNotificationManager.SetUsePlayPauseActions(false);
        }
Exemple #2
0
 public override void OnDestroy()
 {
     // Service is being killed, so make sure we release our resources
     PlayerNotificationManager.SetPlayer(null);
     MediaManager.MediaPlayer.Dispose();
     MediaManager.MediaPlayer = null;
     MediaSession.Release();
     StopForeground(true);
 }