Android Question Mute movie on playing on VideoViewExt

microbox

Active Member
Licensed User
How can I mute movie playing on VideoViewExt but I am able to play/hear my other media file on MediaPlayer?

Thanks in advance,
microbox
 

microbox

Active Member
Licensed User
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
Hi Erel, I can not compile due to this line error.
ToForum.png

BTW in my Sub Globals I declared Dim vv As VideoViewExt
 

microbox

Active Member
Licensed User
Change Array to Array As Object.
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.
B4X:
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
But it's giving me an error "An error has occurred in sub:java.lang.NullPointException"

Thank you for helping out..
 

microbox

Active Member
Licensed User
I got it working with the following code..
B4X:
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
but I'm having trouble due to error
B4X:
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
What do you think I'm missing?
 

microbox

Active Member
Licensed User
I figured it out what I did wrong...I have the file path corrected. Sorry for all.
 

microbox

Active Member
Licensed User
Hi everyone... I put 2 movies . First movie plays muted but when calling the next movie file, it is giving an error message
B4X:
An error has occured in sub:main_vv_complete(java line:450)
java.lang.NullPointerException Continue?
What am doing wrong?

Thanks in advance

B4X:
** 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
 
Last edited:

microbox

Active Member
Licensed User
I tried almost everything.. but still can not find a way to play and mute the second movie file after the first. :(
 
Last edited:
Top