Android Question [solved] CamEx2 Problem with Video

Discussion in 'Android Questions' started by DonManfred, Nov 15, 2018.

  1. DonManfred

    DonManfred Expert Licensed User

    I use CamEx2 (and Camera2 library).
    The same code in another app does work. But in my new app it raises an Error.

    Permission for write external storage is Requested using RuntimePermission and it is granted.

    Code:
    cam.Initialize(pnlCamera)
        
    Log(cam.SupportedHardwareLevel)
        buttons = 
    Array(btnMode)
        SetState(
    FalseFalse, VideoMode)
    Code:
    Sub Activity_Resume
        
    Log("CaptureVideo.Activity_Resume")
        OpenCamera(frontCamera)
    End Sub
    Sub CheckAllFieldsValid
        
    Dim valid As Boolean = DialogKommentar.Text.Length > 0
        DetailsDialog.GetButton(
    DialogResponse.POSITIVE).Enabled = valid
    End Sub
    Sub DialogKommentar_TextChanged (alt As String, Neu As String)
        CheckAllFieldsValid
    End Sub
    Sub OpenCamera (front As Boolean)
        
    Log($"CaptureVideo.OpenCamera(${front})"$)
        rp.CheckAndRequest(rp.PERMISSION_CAMERA)
        
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        
    If Result = False Then
            
    ToastMessageShow("No permission!"True)
            
    Return
        
    End If
        rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
        
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        
    If Result = False Then
            
    ToastMessageShow("No permission!"True)
            
    Return
        
    End If
        rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
        
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        
    If Result = False Then
            
    ToastMessageShow("No permission to external SDCard!"True)
            
    Return
        
    End If
        
        SetState(
    FalseFalse, VideoMode)
        
    Wait For (cam.OpenCamera(front)) Complete (TaskIndex As Int)
        
    If TaskIndex > 0 Then
            MyTaskIndex = TaskIndex 
    'hold this index. It will be required in later calls.
            Wait For(PrepareSurface) Complete (Success As Boolean)
        
    End If
        
    Log("Start success: " & Success)
        SetState(Success, 
    False, VideoMode)
        
    If Success = False Then
            
    ToastMessageShow("Failed to open camera"True)
        
    End If
        
    'Log(cam.ActiveArraySize)
        'Log(cam.PreviewSize)
        'Log(cam.CaptureSize)
    End Sub

    Sub PrepareSurface As ResumableSub
        
    Log($"PrepareSurface)"$)
        SetState(
    False, busystate, VideoMode)
        
    'sizes can be modified here
        If VideoMode Then
            cam.PreviewSize.Initialize(
    640480)
            
    'Using a temporary file to store the video.
            Wait For (cam.PrepareSurfaceForVideo(MyTaskIndex, VideoFileDir, "temp-" & VideoFileName)) Complete (Success As Boolean)
        
    Else
            cam.PreviewSize.Initialize(
    19201080)
            
    Wait For (cam.PrepareSurface(MyTaskIndex)) Complete (Success As Boolean)
        
    End If
        
    If Success Then cam.StartPreview(MyTaskIndex, VideoMode)
        SetState(Success, busystate, VideoMode)
        
    Return Success
    End Sub
    Any hints are higly appreciated.
     
  2. MarkusR

    MarkusR Well-Known Member Licensed User

    i can't follow this path
    Code:
    , VideoFileDir, "temp-" & VideoFileName)
     
    DonManfred likes this.
  3. DonManfred

    DonManfred Expert Licensed User

    :oops:
    b4a can not follow too. I forgot to set two variables to the right values (they are set in the other app on a different place).

    Thank you!

    Now i run into another problem.
    but i´ll create a new Thread about this Issue.
     
    MarkusR likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice