/// <summary>
        /// Updates the metadata on the lock screen
        /// </summary>
        /// <param name="currentTrack"></param>
        internal void UpdateMetadata(IMediaFile currentTrack)
        {
            MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();

            if (currentTrack != null)
            {
                builder
                .PutString(MediaMetadata.MetadataKeyAlbum, currentTrack.Metadata.Artist)
                .PutString(MediaMetadata.MetadataKeyArtist, currentTrack.Metadata.Artist)
                .PutString(MediaMetadata.MetadataKeyTitle, currentTrack.Metadata.Title);
            }
            else
            {
                builder
                .PutString(MediaMetadata.MetadataKeyAlbum,
                           CurrentSession?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyAlbum))
                .PutString(MediaMetadata.MetadataKeyArtist,
                           CurrentSession?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyArtist))
                .PutString(MediaMetadata.MetadataKeyTitle,
                           CurrentSession?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyTitle));
            }

            builder.PutBitmap(MediaMetadata.MetadataKeyAlbumArt, currentTrack?.Metadata.AlbumArt as Bitmap);
            CurrentSession?.SetMetadata(builder.Build());
        }
        /// <summary>
        /// Updates the metadata on the lock screen
        /// </summary>
        private void UpdateMediaMetadataCompat(MediaMetadataRetriever metaRetriever = null)
        {
            if (mediaSessionCompat == null)
            {
                return;
            }

            MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();

            if (metaRetriever != null)
            {
                builder
                .PutString(MediaMetadata.MetadataKeyAlbum, metaRetriever.ExtractMetadata(MetadataKey.Album))
                .PutString(MediaMetadata.MetadataKeyArtist, metaRetriever.ExtractMetadata(MetadataKey.Artist))
                .PutString(MediaMetadata.MetadataKeyTitle, metaRetriever.ExtractMetadata(MetadataKey.Title));
            }
            else
            {
                builder
                .PutString(MediaMetadata.MetadataKeyAlbum, mediaSessionCompat.Controller.Metadata.GetString(MediaMetadata.MetadataKeyAlbum))
                .PutString(MediaMetadata.MetadataKeyArtist, mediaSessionCompat.Controller.Metadata.GetString(MediaMetadata.MetadataKeyArtist))
                .PutString(MediaMetadata.MetadataKeyTitle, mediaSessionCompat.Controller.Metadata.GetString(MediaMetadata.MetadataKeyTitle));
            }
            builder.PutBitmap(MediaMetadata.MetadataKeyAlbumArt, Cover as Bitmap);

            mediaSessionCompat.SetMetadata(builder.Build());
        }
        private void UpdateMediaMetadataCompat(MediaMetadataRetriever metaRetriever = null)
        {
            if (_mediaSessionCompat != null)
            {
                MainActivity.Instance.RunOnUiThread(() =>
                {
                    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
                    var item = _mediaSessionCompat.SessionToken;
                    if (metaRetriever != null)
                    {
                        builder
                        .PutString(MediaMetadata.MetadataKeyAlbum, metaRetriever.ExtractMetadata(MetadataKey.Album))
                        .PutString(MediaMetadata.MetadataKeyArtist, metaRetriever.ExtractMetadata(MetadataKey.Artist))
                        .PutString(MediaMetadata.MetadataKeyDisplayTitle, metaRetriever.ExtractMetadata(MetadataKey.Title));
                    }
                    else
                    {
                        builder
                        .PutString(MediaMetadata.MetadataKeyAlbum, _queue[_pos].Album)
                        .PutString(MediaMetadata.MetadataKeyArtist, _queue[_pos].Artist)
                        .PutString(MediaMetadata.MetadataKeyDisplayTitle, _queue[_pos].Title);
                    }

                    if (!String.IsNullOrEmpty(_queue[_pos].Image.ToString()))
                    {
                        Bitmap artwork = BitmapFactory.DecodeFile(_queue[_pos].Image.ToString());
                        builder.PutBitmap(MediaMetadataCompat.MetadataKeyAlbumArt, artwork);
                        builder.PutBitmap(MediaMetadataCompat.MetadataKeyArt, artwork);
                    }

                    _mediaSessionCompat.SetMetadata(builder.Build());
                });
            }
        }
Beispiel #4
0
        public void UpdateMetadata(IMediaFile currentTrack)
        {
            MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();

            if (currentTrack != null)
            {
                builder
                .PutString(MediaMetadata.MetadataKeyAlbum, currentTrack.Metadata.Album)
                .PutString(MediaMetadata.MetadataKeyArtist, currentTrack.Metadata.Artist)
                .PutString(MediaMetadata.MetadataKeyTitle, currentTrack.Metadata.Title);
            }
            else
            {
                builder
                .PutString(MediaMetadata.MetadataKeyAlbum,
                           Session?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyAlbum))
                .PutString(MediaMetadata.MetadataKeyArtist,
                           Session?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyArtist))
                .PutString(MediaMetadata.MetadataKeyTitle,
                           Session?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyTitle));
            }

            var resources = _applicationContext.Resources;

            //TODO add option to use either PVL, Poniverse, Station or Album art to Options (and here)
            //builder.PutBitmap(MediaMetadata.MetadataKeyAlbumArt, currentTrack?.Metadata.AlbumArt as Bitmap);

            // Uncomment these lines and replace the "splash" with your own drawable resource to use a lock screen pic
            //var id = Resource.Drawable.ic_vol_type_tv_dark;
            //var art = BitmapFactory.DecodeResource(resources, id);
            //builder.PutBitmap(MediaMetadata.MetadataKeyAlbumArt, art);

            Session?.SetMetadata(builder.Build());
        }
Beispiel #5
0
        public void SetMetadata(string artist, string title, Action <MediaMetadataCompat.Builder> build = null)
        {
            var builder = new MediaMetadataCompat.Builder()
                          .PutString(MediaMetadata.MetadataKeyArtist, artist)
                          .PutString(MediaMetadata.MetadataKeyTitle, title);

            build?.Invoke(builder);

            _session.SetMetadata(builder.Build());
        }
        public RadioStationMediaSession SetMetadata(string artist, string title, TimeSpan duration, Action <MediaMetadataCompat.Builder> build = null)
        {
            var builder = new MediaMetadataCompat.Builder()
                          .PutString(MediaMetadata.MetadataKeyArtist, artist)
                          .PutString(MediaMetadata.MetadataKeyTitle, title)
                          .PutLong(MediaMetadata.MetadataKeyDuration, (long)Math.Ceiling(duration.TotalMilliseconds));

            build?.Invoke(builder);

            _session.SetMetadata(builder.Build());

            return(this);
        }
        /// <summary>
        /// Updates the metadata on the lock screen
        /// </summary>
        /// <param name="currentTrack"></param>
        internal void UpdateMetadata(IMediaFile currentTrack)
        {

            MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();

            if (currentTrack != null)
            {
                builder
                    .PutString(MediaMetadata.MetadataKeyAlbum, currentTrack.Metadata.Artist)
                    .PutString(MediaMetadata.MetadataKeyArtist, currentTrack.Metadata.Artist)
                    .PutString(MediaMetadata.MetadataKeyTitle, currentTrack.Metadata.Title);
            }
            else
            {
                builder
                    .PutString(MediaMetadata.MetadataKeyAlbum,
                        CurrentSession?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyAlbum))
                    .PutString(MediaMetadata.MetadataKeyArtist,
                        CurrentSession?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyArtist))
                    .PutString(MediaMetadata.MetadataKeyTitle,
                        CurrentSession?.Controller?.Metadata?.GetString(MediaMetadata.MetadataKeyTitle));
            }

            builder.PutBitmap(MediaMetadata.MetadataKeyAlbumArt, currentTrack?.Metadata.AlbumArt as Bitmap);
            CurrentSession?.SetMetadata(builder.Build());
        }
        /// <summary>
        /// Updates the metadata on the lock screen
        /// </summary>
        private void UpdateMediaMetadataCompat (MediaMetadataRetriever metaRetriever = null)
        {
            if (mediaSessionCompat == null)
                return;

            MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder ();

            if (metaRetriever != null) {
                builder
                .PutString (MediaMetadata.MetadataKeyAlbum, metaRetriever.ExtractMetadata (MetadataKey.Album))
                .PutString (MediaMetadata.MetadataKeyArtist, metaRetriever.ExtractMetadata (MetadataKey.Artist))
                .PutString (MediaMetadata.MetadataKeyTitle, metaRetriever.ExtractMetadata (MetadataKey.Title));
            } else {
                builder
                    .PutString (MediaMetadata.MetadataKeyAlbum, mediaSessionCompat.Controller.Metadata.GetString (MediaMetadata.MetadataKeyAlbum))
                    .PutString (MediaMetadata.MetadataKeyArtist, mediaSessionCompat.Controller.Metadata.GetString (MediaMetadata.MetadataKeyArtist))
                    .PutString (MediaMetadata.MetadataKeyTitle, mediaSessionCompat.Controller.Metadata.GetString (MediaMetadata.MetadataKeyTitle));
            }
            builder.PutBitmap (MediaMetadata.MetadataKeyAlbumArt, Cover as Bitmap);

            mediaSessionCompat.SetMetadata(builder.Build());
        }