VideoView is an object that makes it quite simple to play local or remote videos.
The most important thing to remember about VideoView is that the object itself is not a View (unlike in B4A). The view is exposed through its View property.
In order to play a video you need to:
1. Initialize VideoView.
2. Add VideoView.View to the layout.
3. Load the video with VideoView.LoadVideo or VideoView.LoadVideoUrl (for video streams).
The Ready event is raised when the video is ready for playback.
The Complete event is raised when the playback reaches the end.
Camera object allows you to take pictures, capture videos and also to select exiting pictures and videos from the device albums. Note that it only supports portrait orientation.
The main methods are:
Camera.TakePicture - Opens the Camera form and allows the user to take a picture.
Camera.TakeVideo - Opens the form and allows the user to capture video.
Camera.SelectFromSavedPhotos / SelectFromPhotoLibrary - Open the form and allows the user to select a picture or video from the device camera roll album or device photo library.
On iPads the existing media selection form is anchored to a view.
The complete event will be raised when the user closes the form:
If Success is true then either Image will be initialized and will hold the selected / taken photo or VideoPath will hold the path to the selected / captured video.
Starting from iOS 10 you need to add explanation about the camera usage:
iOS 11+ also requires:
The most important thing to remember about VideoView is that the object itself is not a View (unlike in B4A). The view is exposed through its View property.
In order to play a video you need to:
1. Initialize VideoView.
2. Add VideoView.View to the layout.
3. Load the video with VideoView.LoadVideo or VideoView.LoadVideoUrl (for video streams).
The Ready event is raised when the video is ready for playback.
The Complete event is raised when the playback reaches the end.
Camera object allows you to take pictures, capture videos and also to select exiting pictures and videos from the device albums. Note that it only supports portrait orientation.
The main methods are:
Camera.TakePicture - Opens the Camera form and allows the user to take a picture.
Camera.TakeVideo - Opens the form and allows the user to capture video.
Camera.SelectFromSavedPhotos / SelectFromPhotoLibrary - Open the form and allows the user to select a picture or video from the device camera roll album or device photo library.
On iPads the existing media selection form is anchored to a view.
The complete event will be raised when the user closes the form:
B4X:
Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
If Success Then
If Image.IsInitialized Then
vv.View.Visible = False
ImageView1.Bitmap = Image
Else
vv.View.Visible = True
vv.LoadVideo(VideoPath, "")
End If
End If
End Sub
Starting from iOS 10 you need to add explanation about the camera usage:
B4X:
#PlistExtra:<key>NSPhotoLibraryUsageDescription</key><string>Select a photo.</string>
#PlistExtra:<key>NSCameraUsageDescription</key><string>Taking a photo.</string>
#PlistExtra:<key>NSMicrophoneUsageDescription</key><string>Record video.</string>
iOS 11+ also requires:
B4X:
#PlistExtra:<key>NSPhotoLibraryAddUsageDescription</key><string>Save photo in albums.</string>
Attachments
Last edited: