Android Question how i do for record a video with the camera front?

oscar cabrales

Member
Licensed User
Longtime User
hi, i need record video with the camera front, i get perfect with the camera of back, how i do for record a video with the camera front? this is me code that i must change?

B4X:
'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim timer1 As Timer

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
Dim record As RSVideoRecord
    Dim Panel1 As Panel
    Dim vv As VideoView
    Dim cnt1 As Byte
 

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
Activity.AddMenuItem("Rec","mnurec")
Activity.AddMenuItem("Play","mnuplay")
timer1.Initialize("timer1",1000)
timer1.Enabled = False

'cnt1=0
End Sub




Sub record_Ready (Success As Boolean)
    If Success Then
        record.StartPreview
        ToastMessageShow("Preview iniciado.",False)
     
    Else
        ToastMessageShow("camara no abierta", True)
    End If
End Sub
Sub Activity_Resume
    record.Initialize(Panel1, "record")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    record.Release
End Sub

Sub inicializacion_camara
    'Check http://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html#CAMCORDER
    'For the constants
 
    record.unlockCamera
    record.initMediaRecorder()
    record.AudioSource = 5

    record.VideoSource= 0
    record.OutputFormat = 0
    record.setScreenSize(640,480)
 
    record.AudioEncoder = 1
    record.VideoEncoder = 3
    'record.Profile = 1
    'record.setOutputFile(File.DirDefaultExternal,"watch.3gp")
    record.setOutputFile(File.DirRootExternal,"videosecurity.3gp")
    record.setPreviewDisplay
 
 
    'ToastMessageShow("Initialized.",False)
End Sub
Sub Delay(nMilliSecond As Long)
Dim nBeginTime As Long
Dim nEndTime As Long
nEndTime = DateTime.Now + nMilliSecond
nBeginTime = DateTime.Now
Do While nBeginTime < nEndTime
nBeginTime = DateTime.Now
Log(nBeginTime)
If nEndTime < nBeginTime Then
Return
End If
DoEvents
Loop
End Sub

Sub mnurec_Click
    inicializacion_camara
    ToastMessageShow("grabando 12 segundos.",False)
    record.prepare
    record.start
    Delay(12000)
    record.stop
    record.resetMediaRecorder
    record.releaseMediaRecorder
    record.lockCamera
    record.StopPreview
    record.Release
    ToastMessageShow("grabacion finalizada",False)
    record.Initialize(Panel1, "record")
    'insertovideo
    'guardar_in_mysql
    'ToastMessageShow("enviado a mysql",False)
End Sub
Sub mnuplay_Click
    Panel1.Visible = False
 
    Panel1.SendToBack
 
    'Panel1.Enabled = False
    'Panel2.BringToFront
    vv.Initialize("vv")
 
  ' Activity.AddView(vv, 0dip, 0dip, 429dip, 280dip)
    Activity.AddView(vv, 0dip, 0dip, 430dip, 320dip)
    vv.LoadVideo(File.DirRootExternal, "videosecurity.3gp")
 
    vv.Play
    timer1.Enabled = True
 
 
 
 
    'If
    'vv.RemoveView
 
    'End If
 
End Sub
Sub timer1_Tick
cnt1=1+cnt1
If cnt1= 13 Then
'If vv.IsPlaying = false
vv.RemoveView

Panel1.Visible = True
Panel1.BringToFront


timer1.Enabled= False
cnt1=0
' para seguir grabando y ver lo que se graba es necesario soltar record y luego inicializarlo
record.Release
record.Initialize(Panel1, "record")

End If
End Sub
 

oscar cabrales

Member
Licensed User
Longtime User
ok, but i need begin to record from code not by clicking a button(as does the application VideoRecordApp ), exist any form of begin to record from code with the camera front?
 
Upvote 0
Top