audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

the plugin throws exception when resource was not accessable

Open memetea opened this issue 5 years ago • 11 comments

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)

memetea avatar Jan 18 '19 11:01 memetea

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, ); }`

memetea avatar Jan 18 '19 11:01 memetea

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.

erickzanardo avatar Jan 24 '19 11:01 erickzanardo

pass this error through callback is a good choice

memetea avatar Jan 25 '19 09:01 memetea

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?

erickzanardo avatar Jan 25 '19 12:01 erickzanardo

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.

luanpotter avatar Apr 11 '19 00:04 luanpotter

Are you using Audio Cache Class?

praharshbhatt avatar Jun 21 '19 13:06 praharshbhatt

Did anyone get a solution yet?

ashishbairwa avatar Sep 02 '19 10:09 ashishbairwa

Audio Cache load local asset file

Heipi avatar Mar 11 '20 06:03 Heipi

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)

ninest avatar May 04 '20 07:05 ninest

Facing same issue using this plugin

aryan29 avatar May 18 '20 00:05 aryan29

Fixed via 5eeca8940e764546023567fa2f6b1bc3802f97d3 for android. Now throwing correctly on the dart side. Can anyone confirm for ios? May needs to be added to tests.

Gustl22 avatar Aug 23 '22 20:08 Gustl22

Mark this as stale, as it's most probably fixed.

Gustl22 avatar Jan 21 '23 16:01 Gustl22