User Tools

Site Tools


script-capture-download-delete

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

script-capture-download-delete [2018/03/30 16:59] (current)
teq created
Line 1: Line 1:
 +====== Capture - Download - Delete example ======
 +This example executes the following steps:
 +  - Connect the script to the currently connected camera.
 +  - Start recording.
 +  - Wait for recording to finish.
 +  - Get list of media from the camera.
 +  - Download the latest media item from the camera. The media is automatically deleted from the camera when the download succeeds.
  
 +
 +<code javascript>​
 +// Use the currently connected camera:
 +var connectResult = connectToCamera();​
 +if (connectResult.ok) {
 +    var cameraName = connectResult.message;​
 +
 +    // Capture
 +    var result = startRecording(cameraName);​
 +    if (!result.ok) {
 +        logMessage("​Error capturing: " + result.message,​ true);
 +        return;
 +    }
 +
 +    // Wait until capturing has finished
 +    result = waitForCameraRecordingState(cameraName,​ 0, "​idle"​);​
 +    ​
 +    // Load the media list from the camera
 +    var mediaList = getMediaList(cameraName,​ true);
 +
 +    // Download the last media item
 +    // Media items are sorted by date (descending),​ thus we use the first one.
 +    // After download the media item is deleted.
 +    if (mediaList.length > 0) {
 +        var result = downloadMedia(cameraName,​ mediaList[0].mediaKey,​ "",​ true, false);
 +        if (!result.ok) {
 +            logMessage("​Download error: " + result.message,​ true);
 +        }
 +    }
 +}
 +else logMessage("​No camera found"​);​
 +
 +</​code>​
script-capture-download-delete.txt ยท Last modified: 2018/03/30 16:59 by teq