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

Android: Catch IllegalStateException on local file playback #205

Merged
merged 1 commit into from
Jun 16, 2017

Conversation

benvium
Copy link
Collaborator

@benvium benvium commented Jun 16, 2017

In the process of building a much better test harness in react-native-sound-demo I found that local file playback was broken in Android. This fixes it.

@benvium benvium merged commit ff7a633 into master Jun 16, 2017
@benvium benvium deleted the fix_android_file_audio branch June 16, 2017 09:36
try {
player.prepareAsync();
} catch (IllegalStateException ignored) {
// When loading files from a file, we useMediaPlayer.create, which actually
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this not mean we never invoke our callback? Can we detect the state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AFAIK that exception is only thrown if the preparation has already been done. Actual errors should still happen.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but callback would never be invoked, which means react native is never informed. Unless onPrepared is invoked each time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

... and detecting the state isn't possible. There's no 'isPrepared' or 'getState' on MediaPlayer :-(

Copy link
Contributor

Choose a reason for hiding this comment

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

If onPrepared isn't invoked, we could split the creation to a file based media player, and an http/s based one

aidan-doherty pushed a commit to aidan-doherty/react-native-sound that referenced this pull request Oct 26, 2020
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