Try this:
B4X:Dim r As Reflector r.Target = videoview1 Dim mpo As JavaObject = r.GetField("mMediaPlayer") mpo.RunMethod("setVolume", Array(0, 0)) 'or 1, 1 for full volume
I'm sorry I got to reply late on this thread, I was busy with my work. I'm still having trouble with the following code to mute a video. Below is what I'm using to test.Change Array to Array As Object.
Sub Activity_Create(FirstTime As Boolean)
Try
vv.Initialize("vv")
Catch
Msgbox("Error","")
End Try
Videopnl.Initialize("")
Videopnl.AddView(vv, 0dip, 0dip, Videopnl.Width , Videopnl.Height)
vv.LoadVideo(File.DirRootExternal, "DCIM/Camera/Myvideo.mp4") 'for streaming local files
vv.MediaControllerEnabled=True
vv.Play
Dim r As Reflector
r.Target = vv
Dim mpo As JavaObject = r.GetField("mMediaPlayer")
mpo.RunMethod("setVolume", Array As Object(0, 0)) 'or 1, 1 for full volume
End Sub
Sub Process_Globals
Dim sd As MediaPlayer
End Sub
Sub Globals
Private Videopnl As Panel
Private btnChime As Button
Dim mypath As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
sd.Initialize ()
Dim vv As VideoViewExt
vv.Initialize("vv")
Videopnl.AddView(vv, 0dip, 0dip, Videopnl.Width , Videopnl.Height)
vv.LoadVideo(File.DirRootExternal, "DCIM/Camera/Myvideo.mp4")
vv.MediaControllerEnabled = True
vv.Play
CallSubDelayed2(Me, "MuteVideo", vv)
End Sub
Sub MuteVideo (vv As VideoViewExt)
Dim r1, r2 As Reflector
r1.Target = vv
r1.Target = r1.GetField("mMediaPlayer")
If r1.Target = Null Then
CallSubDelayed2(Me, "MuteVideo", vv)
Return
End If
Dim mp As MediaPlayer
r2.Target = mp
r2.SetField2("mp", r1.Target)
mp.SetVolume(0,0)
'-------------------------------------
End Sub
End Sub
Sub btnChime_Click
mypath = "DCIM/Camera"
sd.Load(mypath,"tada.wav")
playque
End Sub
Sub playque
sd.SetVolume(1,1)
sd.play
End Sub
java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer.prepare(Native Method)
at anywheresoftware.b4a.objects.MediaPlayerWrapper.Load(MediaPlayerWrapper.java:86)
at b4a.example.main._btnchime_click(main.java:315)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66)
at android.view.View.performClick(View.java:3131)
at android.view.View$PerformClick.run(View.java:12035)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: Prepare failed.: status=0x1
An error has occured in sub:main_vv_complete(java line:450)
java.lang.NullPointerException Continue?
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_vv_complete (java line: 462)
java.lang.NullPointerException
at b4a.example.main._vv_complete(main.java:462)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at ice.vvewrap$1.onCompletion(vvewrap.java:32)
at ice.videoviewExt$3.onCompletion(videoviewExt.java:308)
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1489)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException