1

I am trying to play a list of media items with CrossMediaManager. However, in IOS it throws a weired error and doesn't perform playing, while the same code works in Android. If I do pass a single string url or media item then it works, but it doesn't work with multiple urls.

    static async Task<MediaItem> GenerateReciterMediaItem(string fileUri, AudioReciter reciter, byte chapterId)
    {
         Chapter c = await Chapter.GetChapterAsync(chapterId);
         var item = (MediaItem)await CrossMediaManager.Current.Extractor.CreateMediaItem(fileUri);
         item.MediaType = MediaType.Audio;
         var reciterImageUri = Path.Combine("http://www.azee.tech/reciters/r9.png"); //doesn't work
         //another url for image reciter.azee.tech/r9.png --> also doesn't work
         var image = new Image() { Source = ImageSource.FromUri(new Uri(reciterImageUri))};
         int type = 1;
         if (item != null)
         {
            item.Id = string.Format("{0},{1},{2}", type, chapterId, reciter.ReciterID);
            item.IsMetadataExtracted = false;
            item.Title = reciter.Name;
            item.Album = string.Format("{0} - {1} ({2})", c.ChapterID, c.ArabicEnglishName, c.EnglishName);
            item.Artist = reciter.Name;
            item.AlbumImage = image;
            item.AlbumImageUri = reciterImageUri;
            item.DisplayImage = image;
            item.DisplayImageUri = reciterImageUri;
            item.Image = image;
            item.ImageUri = reciterImageUri;
         }
     return item;
 }

static async Task AddAudioReciterTrackToQueue()
{
  //list of urls --> https://www.azee.tech/MaherAlMuaiqly64kbps/001.mp3 , 002.mp3, 003.mp3 and so on
  foreach(var url in listOfUrls)
  {
      var fileUri = listOfUrls[i];
      var item = await GenerateReciterMediaItem(fileUri, type, reciter, chapterId);
      CrossMediaManager.Current.Queue.Add(item);
   }
}
async Task PlayQueue()
{
    CrossMediaManager.Current.AutoPlay = true;
    await AddAudioReciterTrackToQueue();
    
    await CrossMediaManager.Current.Play(CrossMediaManager.Current.Queue.MediaItems); //doesnt work
    await CrossMediaManager.Current.Play(); //doesn't work
}

Error from debug

2020-09-15 22:31:43.550896+0100 wQuran.iOS[29476:23403374] -[AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys ( albumName, author, title, artist ). [0:] state changed Buffering Thread started: #22 2020-09-15 22:31:43.758802+0100 wQuran.iOS[29476:23404151] -[AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys ( artwork ).

If I download the file and play it from Local resource. No error. I have also added Transport Security in info.plist to ignore https from this domain

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
    <key>www.azee.tech</key>
    <dict>
      <key>NSExceptionRequiresForwardSecrecy</key>
      <false/>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSIncludesSubdomains</key>
      <true/>
    </dict>
  </dict>
</dict>
ARH
  • 1,566
  • 3
  • 25
  • 56
  • Can you check if the items have been download successfully and added to the queue successfully? – nevermore Sep 16 '20 at 05:46
  • @ARH were you able to figure this out? I am playing files that are stored in the App Cache and get the same messages, although they don't hinder playback, would like to figure out how to get rid of them. – Reza Dec 07 '21 at 18:43
  • I solved the issue, but I couldn't add them like a list as in the code. I used to play one media and only one media was in the list. However, if you are trying to play a list, I suggest to pass an array of songs not the way in the code. – ARH Dec 07 '21 at 21:00

0 Answers0