saveVideoToPhotosAlbum(params: Object)

Requires:
BaseKit≥2.5.0@ray-js/ray≥0.5.9
Platforms:
iOSAndroid
import { saveVideoToPhotosAlbum } from '@ray-js/ray';

// Promise usage
try {
  const res = await saveVideoToPhotosAlbum({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Save video to the system photo album. Supports MP4 format and requires album permission

Parameters

PropertyTypeRequiredDefaultDescriptionBaseKit Since
filePathstringYes-Video file path; can be a temporary or permanent file path (local path)-
modifyCreationDatebooleanNofalseWhether to modify the video's creation date Default: false (do not modify). true: set the video's creation date to the current save timev3.16.0
complete() => voidNo-Completion callback (executed on both success and failure)-
success(params: Object) => voidNo-Callback on successful API call-
fail(params: Object) => voidNo-Failure callback-
success callback parameters
PropertyTypeDescriptionBaseKit Since
localIdentifierstringAlbum video identifierv3.14.0
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { downloadFile, saveVideoToPhotosAlbum } from '@ray-js/ray'

// Save the video to the system album (requires album permission): download first, then save using the scheme path
downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_video.mp4",
  success: ({ tempFilePath }) => {
    saveVideoToPhotosAlbum({
      filePath: tempFilePath,
      modifyCreationDate: false,
      success: data => console.log("Saved, album identifier:", data.localIdentifier),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});