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

Fix android crash Dispose() call in PlaybackEnded event #122

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

ndegheselle
Copy link
Contributor

Allow the creation of a IAudioPlayer that will be disposed imediatly after ending.

IAudioPlayer player = _audioManager.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("sound.mp3");
player.PlaybackEnded += (s, e) =>
{
    player.Dispose();
};
player.Play();

- Fix warning "mediaplayer went away with unhandled events"
Comment on lines 307 to 311
if (isDisposed)
{
return;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this. I am wondering if this is the correct fix or whether we should move the PlaybackEnded?.Invoke(this, e); line to the end of this method?

I can't decide which is best. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably the state in which you expect the player to be then PlaybackEnded is called is the end of the playback position so I would say it's fine like that. But after checking the other place where PlaybackEnded is called seems like it's always the opposite with a Seek(0) before PlaybackEnded?.Invoke() so it's probably better to keep it coherent.

I will check if that's work fine and update the PR if you good with this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great! Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great! Thank you

Updated

Copy link
Collaborator

@bijington bijington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!

@bijington bijington merged commit 2b53e19 into jfversluis:main Sep 6, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants