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

Constant crash on android 6.0.1 #1727

Open
2 tasks done
ehtiqamar opened this issue Dec 12, 2023 · 4 comments
Open
2 tasks done

Constant crash on android 6.0.1 #1727

ehtiqamar opened this issue Dec 12, 2023 · 4 comments
Labels
bug platform-android Affects the android platform

Comments

@ehtiqamar
Copy link

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

After the update to audioplayers 5.2.1, there is constant crash of IlllegalStateException on Android 6.0.1 devices.

Expected behaviour

The player should play the audio from assets.

Steps to reproduce

  1. Execute flutter run on the code sample
  2. ...
  3. ...

Code sample

Future play(String fileName, {bool loop = false}) async {
if (_audioPlayer.state == PlayerState.disposed) {
_audioPlayer = AudioPlayer();
}
await _audioPlayer.release();
_audioPlayer.play(AssetSource('sounds/$fileName'), volume: _volume);
if (loop) {
_audioPlayer.setReleaseMode(ReleaseMode.loop);
}
}

Affected platforms

Android

Platform details

Platform: Android 6.0.1

AudioPlayers Version

5.2.1

Build mode

release

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(AndroidAudioError, null, java.lang.IllegalStateException
at android.media.MediaPlayer.prepareAsync(Native Method)
at n9.i.d()
at n9.o.N()
at m9.m.J()
at m9.m.n()
at m9.m$b.b()
at m9.m$b.invoke()
at m9.m$d.invokeSuspend()
at kotlin.coroutines.jvm.internal.a.resumeWith()
at d9.d1.run()
at kotlinx.coroutines.internal.n.run()
at kotlinx.coroutines.scheduling.k.run()
at kotlinx.coroutines.scheduling.a.M()
at kotlinx.coroutines.scheduling.a$c.d()
at kotlinx.coroutines.scheduling.a$c.n()
at kotlinx.coroutines.scheduling.a$c.run()
, null)
at StandardMethodCodec.decodeEnvelope(message_codecs.dart:652)
at MethodChannel._invokeMethod(platform_channel.dart:310)
at AudioPlayer.stop(audioplayer.dart:226)
at AudioPlayer.release(audioplayer.dart:242)
at AudioPlayer.dispose(audioplayer.dart:405)
at AudioManager._disposeMusic(audio_manager.dart:112)
at AudioManager.dispose(audio_manager.dart:99)

Related issues / more information

No response

Working on PR

no way

@ehtiqamar ehtiqamar added the bug label Dec 12, 2023
@Gustl22
Copy link
Collaborator

Gustl22 commented Dec 12, 2023

Try to set the release mode before playing.
Also use await before setReleaseMode and play.

See also #1526

@Gustl22 Gustl22 added the platform-android Affects the android platform label Dec 12, 2023
@ehtiqamar
Copy link
Author

Try to set the release mode before playing. Also use await before setReleaseMode and play.

See also #1526

Ok, I'll try with await, but I don't think that would be cause since this only happens on Android 6.0.1

@tkortekaas
Copy link

@ehtiqamar did you find a solution? I am also struggling with this for Android 6 devices in specific

@ehtiqamar
Copy link
Author

@ehtiqamar did you find a solution? I am also struggling with this for Android 6 devices in specific

nope, I tried the above solution but it is still crashing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-android Affects the android platform
Projects
None yet
Development

No branches or pull requests

3 participants