alekseynemiro / tapplayer

This is small an Android app that allows you to play music files when you click (tap) on a tile.
Apache License 2.0
1 stars 0 forks source link

Application crashes when playing an incorrectly formatted file #7

Closed alekseynemiro closed 1 year ago

alekseynemiro commented 1 year ago
  1. Create a new project.
  2. Go to the tile settings and select the wrong format file.
  3. Save the project.
  4. Open the project and tap on the tile with the wrong file.

Expected Result

The application show error message and continues to work.

Actual Result

The application closes with an error.

alekseynemiro commented 1 year ago
android.runtime.JavaProxyThrowable: System.ArgumentNullException: ArgumentNull_Generic Arg_ParamName_Name, audioStream
   at Plugin.Maui.Audio.AudioManager.CreatePlayer(Stream audioStream)
   at TapPlayer.Maui.ViewModels.TileViewModel.Tap()
   at Microsoft.Maui.Controls.Command.<>c__DisplayClass4_0.<.ctor>b__0(Object o)
   at Microsoft.Maui.Controls.Command.Execute(Object parameter)
   at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager)
   at Microsoft.Maui.Controls.Button.SendClicked()
   at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked()
   at Microsoft.Maui.Handlers.ButtonHandler.OnClick(IButton button, View v)
   at Microsoft.Maui.Handlers.ButtonHandler.ButtonClickListener.OnClick(View v)
   at Android.Views.View.IOnClickListenerInvoker.n_OnClick_Landroid_view_View_(IntPtr , IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V , IntPtr , IntPtr , IntPtr )
 at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method)
 at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:31)
 at android.view.View.performClick(View.java:6304)
 at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1219)
 at android.view.View$PerformClick.run(View.java:24803)
 at android.os.Handler.handleCallback(Handler.java:794)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:176)
 at android.app.ActivityThread.main(ActivityThread.java:6635)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

It looks like this issue is related to the file format. I think, we can try to replace AudioManager with MediaElement.

alekseynemiro commented 1 year ago

It looks like the MediaElement won't work if it's not in the view. This is not very convenient. I had to do strange things. But it works and is better than Plugin.Maui.Audio. At least there is no fall. In any case, this point will need to be reworked in the future.

Implemented in v1.0.2.