Sub vvvit5_Error(MEDIA_ERROR As Int) As Boolean
Log("Error: " & MEDIA_ERROR)
Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
Dim x As B4XLoadingIndicator = v.Tag
x.Hide
End If
Next
Activity.Finish
StartActivity(main)
Return True
End Sub
Resumable subs return type must be ResumableSub (or none).
You should make the return type of the sub ResumableSub. (Btw, the error has nothing to do with MsgboxAsync)
B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As ResumableSub
Log("Error: " & MEDIA_ERROR)
Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
Dim x As B4XLoadingIndicator = v.Tag
x.Hide
End If
Next
Activity.Finish
StartActivity(main)
Return True
End Sub
Error: 1
java.lang.ClassCastException: anywheresoftware.b4a.keywords.Common$ResumableSubWrapper cannot be cast to java.lang.Boolean
at com.tillekesoft.vitamio5.VideoView$3.onError(VideoView.java:332)
at io.vov.vitamio.widget.VideoView$5.onError(VideoView.java:223)
at io.vov.vitamio.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1765)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Please post in full the relevant code sub routines, as all this guessing is getting both yourself and @Computersmith64 absolutely nowhere very slowly...
Thank you for your help.
but
I couldn't do it with the method you specified.
such a method works. The message is waiting for user confirmation and does not give an error.
B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As Boolean
Log("Error: " & MEDIA_ERROR)
videowait
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
Dim x As B4XLoadingIndicator = v.Tag
x.Hide
End If
Next
Return True
End Sub
Sub videowait
Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
Activity.Finish
StartActivity(main)
End Sub
Well I don't know what you were doing, but the code below works as expected. The vvvit5_Error sub is called, the msgbox is displayed & waits for input, then when the OK button is tapped, the vvvit_Error sub resumes, then returns to the line after the original call in Activity_Resume:
B4X:
Sub Activity_Resume
Wait for (vvvit5_Error(1)) Complete (ret As Boolean)
Log("Returned from vvvit5_Error")
End Sub
Sub vvvit5_Error(MEDIA_ERROR As Int) As ResumableSub
Private xui As XUI
Log("Error: " & MEDIA_ERROR)
Log("Waiting for MsgboxAsync result")
Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
Log("Finished waiting for MsgboxAsync result")
Return True
End Sub
Error: 1
Waiting for MsgboxAsync result
java.lang.ClassCastException: anywheresoftware.b4a.keywords.Common$ResumableSubWrapper cannot be cast to java.lang.Boolean
at com.tillekesoft.vitamio5.VideoView$3.onError(VideoView.java:332)
at io.vov.vitamio.widget.VideoView$5.onError(VideoView.java:223)
at io.vov.vitamio.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1765)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)