This is a warp that I have done for @mvpmedia. It is based on this Github project. Have amended the original code somewhat to add the following additional functionality:
1. Take snapshots too (the original project only records video)
2. Define your own images for the buttons to stop/start video recording, swop between back and front camera, and taking snapshots.
3. Define the folder where the videos and snapshots will be stored (starting from the root folder of your device)
4. Added the standard shutter sound when taking a snapshot.
I have "dropped" the APK here for whoever would like to test it.
B4A Sample code:
1. Take snapshots too (the original project only records video)
2. Define your own images for the buttons to stop/start video recording, swop between back and front camera, and taking snapshots.
3. Define the folder where the videos and snapshots will be stored (starting from the root folder of your device)
4. Added the standard shutter sound when taking a snapshot.
I have "dropped" the APK here for whoever would like to test it.
B4A Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: VideoRecordPortrait
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\resource
'IMPORTANT!!!! YOU NEED TO SET THIS PATH CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#Extends: android.support.v7.app.AppCompatActivity
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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.
Private Button1 As Button
Private Label1 As Label
Dim mycam As VideoRecordPortrait
Dim videostartimage As Bitmap
Dim videostopimage As Bitmap
Dim switchcameraimage As Bitmap
Dim takepictureimage As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
mycam.Initialize("mycam")
Label1.Visible = True
Label1.Text = "Wrapped by Johan Schoeman"
videostartimage.Initialize(File.DirAssets,"videostartbutton.png")
videostopimage.Initialize(File.DirAssets,"videostopbutton.png")
switchcameraimage.Initialize(File.DirAssets,"switchcamerabutton.png")
takepictureimage.Initialize(File.DirAssets,"takepicturebutton.png")
mycam.MaximumDuration = 10000 'maximum recording time in milliseconds
mycam.MaximumFileSize = 10000000 'maximum recording files size in bytes - in this case 10MB
mycam.FolderName = "MikesVideoFolder" 'folder where video will be stored - starting from the root folder of your device
'if the folder does not exist it will be created
mycam.VideoName = "MikesVideo" 'file name of the recorded video it will be stored as MikesVideo.mp4
'snapshots will also be stored in this folder
mycam.TimerTextColor = Colors.Green 'text color of the video recording countdown timer
mycam.ShowButtons = True 'show or don't show the buttons
'if you take out the following 4 lines it will revert to the default "button" images
'The custom images are in the /Files folder of the B4A project
'I have downloaded them, resized them to 64 x 64, changed their colors, and made their backgrounds transparent
mycam.StartVideoImage = videostartimage 'the image (for the button) to be displayed for starting a video recording
mycam.StopVideoImage = videostopimage 'the image (for the button) to be displayed to stop the video recording
mycam.CameraSwitchImage = switchcameraimage 'the image (for the button) to be displayed to swop between the front and back cameras
mycam.TakePictureImage = takepictureimage 'the image (for the button) to be displayed for taking snapshots
mycam.ReturnToB4AafterPictureTaken = False 'either return to the B4A project or continue with the preview for another
'snapshot or to record a video
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
mycam.StartCamera
End Sub
Sub mycam_new_video_captured
Log("back in B4A and new VIDEO captured")
End Sub
Sub mycam_new_picture_captured
Log("back in B4A and new PICTURE captured")
End Sub
Last edited: