I have an Activity that plays either a Video or an Audio file.
I am attempting to use the device "Back" button to Stop/Close the video/audio play function if they are still running AND Close the Activity.
I have the following code:
I am doing something dodgy that I can't seem to find.
I receive the following error when I use the above code:
I am attempting to use the device "Back" button to Stop/Close the video/audio play function if they are still running AND Close the Activity.
I have the following code:
B4X:
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
If pnlPlayAudio.Visible = True Then
MediaPlayer1.Stop
timerAudio.Enabled = False
pnlPlayAudio.Visible = False
End If
If vv.IsPlaying = True Then
vv.stop
vv.RemoveView
End If
If pnlPlayAudio.Visible = False And vv.IsPlaying = False Then
Activity.Finish
End If
Else
End If
Return True
End Sub
I am doing something dodgy that I can't seem to find.
I receive the following error when I use the above code:
B4X:
mygallery_activity_keypress (java line: 453)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean ice.videoviewExt.isPlaying()' on a null object reference
at ice.vvewrap.IsPlaying(vvewrap.java:71)
at com.rob.ebuki.mygallery._activity_keypress(mygallery.java:453)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.rob.ebuki.mygallery$HandleKeyDelayed.runDirectly(mygallery.java:228)
at com.rob.ebuki.mygallery$HandleKeyDelayed.run(mygallery.java:225)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5631)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)