Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
770 stars 306 forks source link

Metadata and webradio: how to recover data like on native player? #793

Open pcdus opened 3 years ago

pcdus commented 3 years ago

Hello,

I would like to know how metadata are recovered from a a webradio?

I play an audio stream from an URL with: var mediaItem = await CrossMediaManager.Current.Play(radioUrl);

I also use:

mediaItem.MetadataUpdated += (sender, args) => {
    var title = args.MediaItem.Title;
    Debug.WriteLine(title);
};

and:

CrossMediaManager.Current.MediaItemChanged += OnCurrentMediaItemChanged;

private void OnCurrentMediaItemChanged(object sender, MediaItemEventArgs e)
{
    var currentMedia = e.MediaItem;
    Debug.WriteLine($"OnCurrentMediaItemChanged - currentMedia :  {currentMedia.Title} {currentMedia.Artist}");
}

But these events are never raised.

However, if I push the app in background and I display the native iOS player, the title and artist are well recovered.

How is it possible? Can I recover these data in the app?

pcdus commented 3 years ago

Finally I've found a way to manage this on iOS with MediaItem_PropertyChanged:

Source = await CrossMediaManager.Current.Play(radioUrl);
Source.PropertyChanged += MediaItem_PropertyChanged;
private void MediaItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName == nameof(Source.Artist))
    {
        CurrentArtist = Source.Artist;
    }
    if (e.PropertyName == nameof(Source.Title))
    {
        CurrentTitle = Source.Title;
    }
}

However this doesn't work for Android: is it normal?

pcdus commented 2 years ago

Hello, is there any news about this issue?

I just did some tests with the latest version but this doesn't change anything on Android.