Working with Video Files in the Camera

Working with video files is similar to that of image files, since video and image use the same commands to work with the files. 

Video List

The video files in the storage of the camera can be browsed from the application. The CameraFileListViewActivity class uses the CustomListAdapter class to save information of the videos.

 

The list of videos in the camera is obtained by executing camera.listFiles command. The CameraFileListViewActivity class implements getListFiles() to execute this action. Note that the method is called with mediaType set to “video”.

 

If the camera cannot return the complete list, the continuationToken field is set in the response. Then the client should send camera.listFiles command again to obtain the remaining list of videos. Repeat this command until the last item is obtained. 

Thumbnail List

The sample application shows the thumbnail images as a list on the screen. The getView() method gets a thumbnail view for each video item in the list by using camera.getFile command. It ensures to display multiple thumbnail images in a seamless manner. The sample application assigns maxSize to be 144. 

Video Information

By clicking on the thumbnail image of a video file, the following list dialog is presented. Select ‘Show Information’ to call the getFileMetadata() method and show the video information.

 

android_list_dialog_selected_video.png

 

‘Show Information’ shows a dialog that displays information of the video selected. This information is obtained by camera.getMetadata command. The CameraFileListViewActivity class implements the getFileMetadata() method to execute this action.

 

android_image035.png

Download Video

Select ‘Get Video’ from the list dialog to download the video. camera.getFile command from the getFullFile() method obtains the specified video file from the camera. Make sure to update the HTTP header to include "Accept: video/mp4".

 

android_download_video_1.png

Delete Video

Select ‘Delete’ from the list dialog to delete the video. camera.delete command from the deleteFilesFromCamera() method deletes the specified video file from the camera. The deleteFilesFromCamera() method also updates the list object to remove the item from the list.

 

android_video_delete.png

Record Video

The sample application can control the camera remotely to record video.

 

android_image039.png

 

 

If the ‘SIMPLE RECORDING’ button is clicked, the sample application starts SimpleRecordingActivity which has ‘START RECORDING’ and ‘STOP RECORDING’ buttons (as well as ‘RECORDING STATUS’ and ‘LIVE SNAP SHOT’ buttons). By using these buttons the sample application manages video recording behavior based on the recording status.

 

Video Recording behavior can be modeled by the following state diagram.

 

android_image040.png

 

State Machine Elements

Element

Name

Description

State

STOP

Recording is stopped (initial state)

 

RECORDING

Recording is in progress

 

PAUSED

Recoding is paused

Event(Input)

Start

Start Recording’ button is clicked

 

Stop

Stop Recording’ button is clicked

Action(Output)

START

Send camera.startCapture command.

Toggle ‘Start Recording’ button text to “Pause Recording”.

 

PAUSE

Send camera._pauseRecording command.

Toggle ‘Start Recording’ button text to “Resume Recording”.

 

RESUME

Send camera._resumeRecording command.

Toggle ‘Start Recording’ button text to “Pause Recording”.

 

STOP

Send camera.stopCapture command.

Toggle ‘Start Recording’ button text to “Start Recording”.

 

State Transition Table

Current State

Event(Input)

Next State

Action(Output)

STOP

Start

RECORDING

START

 

Stop

STOP

STOP

RECORDING

Start

PAUSED

PAUSE

 

Stop

STOP

STOP

PAUSED

Start

RECORDING

RESUME

 

Stop

STOP

STOP

 

The following figure shows the UI layout of SimpleRecordingActivity. When entering this Activity, the sample application presents a dialog where the user is able to easily change captureMode option to “video” so that the user can readily use the video recording features.

 

android_image041.png

Recording Status

By clicking the ‘RECORDING STATUS’ button, the sample application checks the recording status of the camera by using camera._getRecordingStatus command (from getRecordingStatus() method). If the camera is not in recording state, camera._getRecordingStatus command returns an error message that indicates the current state of the camera. 

Live Snapshot

By clicking the ‘LIVE SNAP SHOT’ button, the sample application takes a snapshot image while the camera is in recording status by using camera._liveSnapshot command (from liveSnapShot() method). Note that camera._liveSnapshot command can be used only when the camera is in 180° modes; _cameraId option needs to be set to either “half-front-camera” or “half-rear-camera”. 

Looping

If the ‘LOOPING’ button is clicked, the sample application starts LoopingActivity. The following figure shows the layout of the LoopingActivity UI.

 

android_looping.png

 

Set ‘_loopingVideo’ option value ("looping_video_off" "looping_video_5" "looping_video_20" "looping_video_60" "looping_video_120" "looping_video_max") to assign looping minutes. Click the ‘START CAPTURE’ button and the startCaptureLooping() method is called to execute camera.startCapture command with ‘_loopingVideo’ capture mode. The looping capture can be stopped by clicking ‘STOP CAPTURE’ button.

 

Note that Looping is supported on Action CAMLTE only. 

Timelapse

If the ‘TIMELAPSE’ button is clicked, the sample application starts TimelapseActivity. The following figure shows the layout of the TimelapseActivity UI.

 

android_timelapse.png

 

Set ‘_timelapseSpeed’ option value (5/10/15/30/60/150/300/900/1800) to assign timelapse value. Click the ‘START CAPTURE’ button and the startCaptureTimelapse() method is called to execute camera.startCapture command with ‘_timelapseSpeed’ capture mode. The timelapse capture can be stopped by clicking ‘STOP CAPTURE’ button.

 

Note that Timelapse is supported on Action CAMLTE only.

 

 

Navigation