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

Fails on android after a few calls #92

Open
ajmilford opened this issue Feb 21, 2022 · 2 comments
Open

Fails on android after a few calls #92

ajmilford opened this issue Feb 21, 2022 · 2 comments

Comments

@ajmilford
Copy link

In my shared code I have:
called in the constructor of a view (actually a Rg.Plugins.Popup.Pages.PopupPage view):
Stream beepStream = UIBits.ImageFactory.Instance.GetAsset("UIBits.Assets.beep.mp3");
audioPlayer = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
audioPlayer.Load(beepStream);
then later in response to an action:
audioPlayer.Play();

this initially works fine.
But after maybe a dozen times (I haven't actually counted) the sound stops being produced. In the application output I see:

[MediaPlayer-JNI] start
[MediaPlayerNative] start
[MediaPlayerNative] message received msg=300, ext1=0, ext2=0
[MediaPlayerNative] Received SEC_MM_PLAYER_CONTEXT_AWARE
[MediaPlayerNative] callback application
[MediaPlayerNative] back from callback
[MediaPlayerNative] message received msg=100, ext1=1, ext2=-19
[MediaPlayerNative] error (1, -19)
[MediaPlayerNative] callback application
[MediaPlayerNative] back from callback
[MediaPlayer] Error (1,-19)

do I need to do something else when the sound is played to release resources or something? or is this a bug?

@adrianstevens
Copy link
Owner

Can you provide more details? What device are you using? What version of Android? And how frequently are you playing the sound?

@ajmilford
Copy link
Author

I fixed the issue by making 'audioPlayer' a static and modifying the constructor to:

if (audioPlayer != null)
return;
Stream beepStream = UIBits.ImageFactory.Instance.GetAsset("UIBits.Assets.beep.mp3");
audioPlayer = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
audioPlayer.Load(beepStream);

So 'audioPlayer' is only created once.

It is running on a Samsung Galaxy S7 Edge. Not called particularly frequently - minimum time between calls would be 10s.
Android V8.0.0.

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

2 participants