Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleAudioPlayer: object reference error on iOS after playback complete #96

Open
KnoxCameron opened this issue Apr 6, 2022 · 0 comments

Comments

@KnoxCameron
Copy link

I have an app that I wrote and released for Android and am now testing and modifying as required for iOS. I use SimpleAudioPlayer as an easy cross-platform way of playing audio clips.

I only ever need to play one clip at a time, so I wrote the program to instantiate the object and reference the "current" player, similar to:

player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;

I intercept the playback ended event and tell it the next clip to play. This worked fine on Android. On iOS, it threw an error that the object had been modified or no longer existed (sorry I don't have the exact error but can re-created it if necessary). I ended up working around the issue by using the the create player call like this instead:

player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();

And calling this again in each playback ended event to re-create the object, as well as adding the playback ended event again.

Is this difference in behaviour between Android and iOS expected? The code as modified for iOS does also work on Android, but I don't know if there might be side effects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant