.Net MAUI - Android TV - Displaying Now Playing card

Abanoub Zak 31 Reputation points

First of all, I know that Maui not supporting android TV now, however, the code I need for this is included in.NET MAUI from Xamarin Forms and Android.Media.Session

I just can't apply the code correctly or I'm missing something from these documentations

  1. Display a Now Playing card
  2. Implement a media session
  3. MediaSession.NET API browser/Android.Media.Session

Now here is the code I wrote based on these documentations

public static class Declarations
      public static  MediaSession mediaSession = new MediaSession(MainActivity.ActivityCurrent, "myappname") { Active=false};
      public void RegisterNotificationPlayingNowTV()
            global::Android.Content.Intent intent = new global::Android.Content.Intent(this, typeof(MainActivity));
            const int pendingIntentId = 2;
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.Immutable);
            Declarations.mediaSession.SetMetadata(new MediaMetadata.Builder()
            .PutString(MediaMetadata.MetadataKeyArtist, "any name")
            .PutString(MediaMetadata.MetadataKeyAlbum, "any album")
            .PutString(MediaMetadata.MetadataKeyTitle, "any title")
            Declarations.mediaSession.Active = true;

The code doesn't trigger any error, but still, no card is displed when I call that code.

I took a long shot with this project and I'm not ready yet to quit.

I'm planning to add all the fixes I applied for my MAUI Android TV to be approved by Google Play in one article since Microsoft stated that .Net Maui not supporting Android TV, however, it has all the libraries needed and I was able to overcome most of the issues.

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,576 questions
0 comments No comments
{count} votes