I have some code where I record a video and have a imageview on top of my view.
Its recording okay and the image is visible.
Then I put a label on top of my imageview and set a timer to count seconds.
I set the label to BringToFront but when I run my App its behind the imageview.
If I place the label just above the imageview is shown.
Layout is created in designer.
Heres my code:
Its recording okay and the image is visible.
Then I put a label on top of my imageview and set a timer to count seconds.
I set the label to BringToFront but when I run my App its behind the imageview.
If I place the label just above the imageview is shown.
Layout is created in designer.
Heres my code:
B4X:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
'**********************************************
'** Process Globals
'**********************************************
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim CounterTimer As Timer
End Sub
'**********************************************
'** Globals
'**********************************************
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private pnlVideo As Panel
Private btnRecording As ImageView
Private lblCounter As Label
Dim phone As Phone
Dim record As RSVideoRecord '** Bruges til at optage video
Dim theCounter As Int
End Sub
'**********************************************
'** Activity create
'**********************************************
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Try
'** Load layout
Activity.LoadLayout("videoLayout")
If FirstTime = False Then
'** Initialize video
record.Initialize(pnlVideo, "record")
'** Initialize timer
CounterTimer.Initialize("CounterTimer", 1000)
'** Nulstil counter
theCounter = 0
End If
'** Vis knappen
btnRecording.Enabled = True
btnRecording.Visible = True
'** Vis counter
lblCounter.Enabled = True
lblCounter.Visible = True
lblCounter.BringToFront
Catch
Log("Video - Activity_Create - " + LastException.Message)
End Try
End Sub
'**********************************************
'** Activity resume
'**********************************************
Sub Activity_Resume
Try
'** Sæt den til landscape
phone.SetScreenOrientation(0)
'** Initialize video
'record.Initialize(pnlVideo, "record")
'** Sæt record knappen frem
btnRecording.BringToFront
Catch
Log("Video - Activity_Resume - " + LastException.Message)
End Try
End Sub
'**********************************************
'** Activity pause
'**********************************************
Sub Activity_Pause (UserClosed As Boolean)
Try
record.Release
Catch
Log("Video - Activity_Pause - " + LastException.Message)
End Try
End Sub
'**********************************************
'** Recording button
'**********************************************
Sub btnRecording_Click
Try
'** Vis knappen
btnRecording.Enabled = False
btnRecording.Visible = False
'** Skjul knappen
btnRecording.Enabled = False
btnRecording.Visible = False
'** Stop timer
CounterTimer.Enabled = False
'** Release og stop recording
record.stop
record.resetMediaRecorder
record.releaseMediaRecorder
record.lockCamera
'** Sæt den til unspecified
phone.SetScreenOrientation(-1)
'** Sæt at video er optaget
Functions.iVideo = 1
'** Spring til menu
StartActivity(Main)
Activity.Finish
Catch
Log("Video - btnRecording_Click - " + LastException.Message)
End Try
End Sub
'**********************************************
'** Timer events
'**********************************************
Sub CounterTimer_Tick
Try
'** Skriv counter i label
lblCounter.Text = theCounter
'** Increment counter
theCounter = theCounter + 1
Catch
Log("Video - CounterTimer_Tick - " + LastException.Message)
End Try
End Sub
'**********************************************
'** Recording events
'**********************************************
Sub record_Ready (Success As Boolean)
Try
If Success Then
'** Start preview
record.StartPreview
'** Skriv at video er startet
ToastMessageShow("Video optagelse er startet.",False)
'** Enable timer
CounterTimer.Enabled = True
'** Sæt parameter
SetVideoParameter
Else
ToastMessageShow("Kan ikke åbne kamera.", True)
End If
Catch
Log("Video - record_Ready - " + LastException.Message)
End Try
End Sub
Sub SetVideoParameter
Try
'For the constants
record.unlockCamera
record.initMediaRecorder()
record.AudioSource = 5
record.VideoSource = 1
record.OutputFormat = 2
record.setScreenSize(640,480)
record.AudioEncoder = 1
record.VideoEncoder = 3
'record.Profile = 1
record.setOutputFile(File.DirDefaultExternal,"movie.mov")
record.setPreviewDisplay
record.prepare
record.start
Catch
Log("Video - record_Ready - " + LastException.Message)
End Try
End Sub