adrianstevens / Xamarin-Plugins

Cross-platform Plugins for Xamarin, Xamarin.Forms and Windows
https://www.nuget.org/packages/Xam.Plugin.SimpleAudioPlayer/
MIT License
133 stars 53 forks source link

Playing audio works on android and UWP but in iOS reports SecTaskLoadEntitlements failed error=22 #49

Closed GeorgeKiiai closed 5 years ago

GeorgeKiiai commented 5 years ago

I'm new to Xamarin and brand new to the SimpleAudioPlayer. I followed the instructions for adding it to a shared library and it appears to work fine for UWP and Android, but when I attempt to run in on iOS it hangs and reports SecTaskLoadEntitlements failed error = 22. I suspected that I needed to add an entitlement to my iOS app, but there doesn't appear to be one required for playing simple sounds. On the off chance that someone else has experienced this behavior, I'm posting here... Below is the code that causes the issue...

private void PlaySound(string resourceName) { var assembly = typeof(App).GetTypeInfo().Assembly; Stream audioStream = assembly.GetManifestResourceStream("MathFlash.Sounds." + resourceName);

        if (audioStream != null)
        {
            var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
            player.Load(audioStream);
            player.Play();
        }
    }
GeorgeKiiai commented 5 years ago

The MacBook was needing to be paid attention to. I had a box that was prompting the user for permission... MathFlash.ios is wanting to access audio. Allow? The moral of the story is when you develop iOS from a Windows laptop, keep an eye on your MacBook. ;-p