-
Notifications
You must be signed in to change notification settings - Fork 56
[audiofileplayer] NullPointerException #25
Description
First of all, very nice control with clean source code and GREAT comments! Thanks!
There is a corner case that throws an NPE. Steps to recreate:
- Try to load a remote file that is corrupted so that load fails.
- Handle the onError callback and dispose the audio control inside the callback.
- Without doing anything else, let the phone go to sleep.
- The following exception occurs:
I/AudiofileplayerPlugin(26650): onMethodCall: method = load
V/MediaHTTPService(26650): MediaHTTPService(android.media.MediaHTTPService@3cb2af9): Cookies: null
I/AudiofileplayerPlugin(26650): onMethodCall: method = setVolume
V/MediaHTTPService(26650): makeHTTPConnection: CookieManager created: java.net.CookieManager@a2f5a3e
V/MediaHTTPService(26650): makeHTTPConnection(android.media.MediaHTTPService@3cb2af9): cookieHandler: java.net.CookieManager@a2f5a3e Cookies: null
I/AudiofileplayerPlugin(26650): onMethodCall: method = play
E/MediaPlayerNative(26650): error (1, -2147483648)
E/MediaPlayer(26650): Error (1,-2147483648)
E/ManagedMediaPlayer(26650): onError: what:1 extra: -2147483648
I/flutter (26650): OnError called
I/flutter (26650): audio dispose called without awaiting
=== Everything looks good until the phone goes to sleep, then... ===
I/AudiofileplayerPlugin(26650): onMethodCall: method = pause
E/MethodChannel#audiofileplayer(26650): Failed to handle method call
E/MethodChannel#audiofileplayer(26650): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.flutter.plugins.audiofileplayer.ManagedMediaPlayer.pause()' on a null object reference
E/MethodChannel#audiofileplayer(26650): at com.google.flutter.plugins.audiofileplayer.AudiofileplayerPlugin.onMethodCall(AudiofileplayerPlugin.java:107)
E/MethodChannel#audiofileplayer(26650): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#audiofileplayer(26650): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#audiofileplayer(26650): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#audiofileplayer(26650): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#audiofileplayer(26650): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#audiofileplayer(26650): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#audiofileplayer(26650): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#audiofileplayer(26650): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#audiofileplayer(26650): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#audiofileplayer(26650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/DartMessenger(26650): Uncaught exception in binary message listener
E/DartMessenger(26650): java.lang.IllegalStateException: Reply already submitted
E/DartMessenger(26650): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:151)
E/DartMessenger(26650): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:240)
E/DartMessenger(26650): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/DartMessenger(26650): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/DartMessenger(26650): at android.os.MessageQueue.nativePollOnce(Native Method)
E/DartMessenger(26650): at android.os.MessageQueue.next(MessageQueue.java:336)
E/DartMessenger(26650): at android.os.Looper.loop(Looper.java:174)
E/DartMessenger(26650): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/DartMessenger(26650): at java.lang.reflect.Method.invoke(Native Method)
E/DartMessenger(26650): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/DartMessenger(26650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)