'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("1")
buffers.Initialize
timer1.Initialize("timer1", 1000)
End Sub
Private Sub streamer_RecordBuffer (Buffer() As Byte)
buffers.Add(Buffer)
End Sub
Private Sub btnStartRecording_Click
rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
xui.MsgboxAsync("No permission", "")
Return
End If
If streamer.PlayerBufferSize = 0 Then
streamer.Initialize("streamer", 22050, True, 8, streamer.VOLUME_MUSIC)
End If
buffers.Clear
streamer.StartRecording
recordingStart = DateTime.Now
timer1.Enabled = True
Timer1_Tick
btnPlay.Enabled = False
End Sub
Private Sub Timer1_Tick
Label1.Text = "Recording: " & _
Round((DateTime.Now - recordingStart) / DateTime.TicksPerSecond) & " seconds"
End Sub
Private Sub btnStopRecording_Click
streamer.StopRecording
timer1.Enabled = False
btnPlay.Enabled = True
Label1.Text = ""
End Sub