audioplayers
audioplayers copied to clipboard
the plugin throws exception when resource was not accessable
when the resouce was not accessable the plugin throws an exception and it seems that I can't catch it. here's the stacktrace
E/AudioplayersPlugin(21486): java.lang.RuntimeException: Unable to access resource E/AudioplayersPlugin(21486): at xyz.luan.audioplayers.WrappedMediaPlayer.setSource(WrappedMediaPlayer.java:145) E/AudioplayersPlugin(21486): at xyz.luan.audioplayers.WrappedMediaPlayer.setUrl(WrappedMediaPlayer.java:54) E/AudioplayersPlugin(21486): at xyz.luan.audioplayers.AudioplayersPlugin.handleMethodCall(AudioplayersPlugin.java:57) E/AudioplayersPlugin(21486): at xyz.luan.audioplayers.AudioplayersPlugin.onMethodCall(AudioplayersPlugin.java:42)
here's the code
`void buttonPressed() async { try { if (playerState != AudioPlayerState.PLAYING) { await this.audioPlayer.play(this.widget.url); } else { await this.audioPlayer.resume(); } } on PlatformException catch (e) { print("play ${this.widget.url} error: $e"); hasError = true; } setState(() {}); }
@override Widget build(BuildContext context) { Color iconColor = hasError ? Colors.grey : Colors.black; return FlatButton( child: playerState == AudioPlayerState.STOPPED ? Icon(Icons.play_arrow, color:iconColor) : Icon(Icons.pause, color:iconColor), onPressed: hasError ? null : buttonPressed, ); }`
But this is expected right? There is not much to do if the resource is not accessible, and since it is a RuntimeException, it will not be possible for audioplayers to identify that the exception was caused because of an inaccessible resource.
pass this error through callback is a good choice
Hum, I may has not understood correctly your issue then, is this failing silently? You not able to catch this with a try/catch statement?
I think it should throw an error but on the dart side, or at least dart-side-catchable or something. I don't think an error callback is necessary.
Are you using Audio Cache Class?
Did anyone get a solution yet?
Audio Cache load local asset file
I am also getting the same issue. Are there any updates? Edit: It works on IOS if you downgrade to 0.13.2, but it still wasn't working on my Android device
Error message
V/MediaPlayer(27227): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer(27227): cleanDrmObj: mDrmObj=null mDrmSessionId=null V/MediaPlayer(27227): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer(27227): cleanDrmObj: mDrmObj=null mDrmSessionId=null E/AccessibilityBridge(27227): VirtualView node must not be the root node. E/AccessibilityBridge(27227): VirtualView node must not be the root node. I/SessionManager(27227): dispatchVolumeKeyEvent:com.themindstorm.shots true KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_VOLUME_UP, scanCode=115, metaState=0, flags=0x8, repeatCount=0, eventTime=7944810, downTime=7944810, deviceId=6, source=0x101 } -2147483648 false java.lang.Throwable I/SessionManager(27227): at android.media.session.MediaSessionManager.dispatchVolumeKeyEventInternal(MediaSessionManager.java:365) I/SessionManager(27227): at android.media.session.MediaSessionManager.dispatchVolumeKeyEventAsSystemService(MediaSessionManager.java:358) I/SessionManager(27227): at com.android.internal.policy.PhoneWindow.onKeyDown(PhoneWindow.java:1899) I/SessionManager(27227): at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:350) I/SessionManager(27227): at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:5321) I/SessionManager(27227): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5189) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4673) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4726) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4692) I/SessionManager(27227): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4832) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4700) I/SessionManager(27227): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4889) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4673) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4726) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4692) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4700) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4673) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4726) I/SessionManager(27227): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4692) I/SessionManager(27227): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4865) I/SessionManager(27227): at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:5026) I/SessionManager(27227): at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2590) I/SessionManager(27227): at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2100) I/SessionManager(27227): at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2091) I/SessionManager(27227): at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2567) I/SessionManager(27227): at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
Facing same issue using this plugin
Fixed via 5eeca8940e764546023567fa2f6b1bc3802f97d3 for android. Now throwing correctly on the dart side. Can anyone confirm for ios? May needs to be added to tests.
Mark this as stale, as it's most probably fixed.