Baseflow / XamarinMediaManager

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

Ios doesnt play from queue #896

Open Novotnde opened 1 year ago

Novotnde commented 1 year ago

Hello,

i have impelentation of crossmedia manager and i have been experiencing issues with the player on ios. It plays once i pass the file as a parameter but it doesn't if i just add it to the queue and then trz to play. It works very well on android but not on ios. I really don't want to have two implementations. Plus i have been experiencing some buffering on ios.

try
{
    Console.WriteLine("cleaning");
    await CrossMediaManager.Current.Stop();
    CrossMediaManager.Current.Queue.Clear();
    Console.WriteLine("playing " + filename);
    CrossMediaManager.Current.ClearQueueOnPlay = true;
    CrossMediaManager.Current.RepeatMode = RepeatMode.Off;
    CrossMediaManager.Current.Notification.Enabled = false;
    _mediaItem = new MediaItem(filename)
    {
        Album = detail.NameCz,
        AlbumArtist = detail.Narrator,
        DisplayDescription = "description to be filled",
        DisplayTitle = "title to be filled",
        FileName = language + " " + localTrack,
        Title = filename,
        MediaUri = filename,
        Image = ArticleImage
    };
    if (Device.RuntimePlatform == Device.iOS)
       {
            PlayFile(filename);
       }
     else
      {
            CrossMediaManager.Current.Queue.Add(_mediaItem);
            CrossMediaManager.Current.Play();
        }          
}
catch (Exception ex)
{
    _ = LangUpGlobalExceptionHandler.LogException(ex);
    if (LangUpNetworkDelegate.IsOnline)
    {
        NotificationService.ShowToast(
            "Při přehrávání se vyskytla chyba, zkuste to později prosím.");
    }
    else
    {
        NotificationService.ShowToast(
            "Problém s připojením k internetu, zkuste to později prosím.");
    }
}