my.saveVideoToPhotosAlbum

Call this JSAPI to save the video file to the album.

Notes:

  • Supported SDK versions: 2.75.0
  • Supported types of mini programs: DSL, H5+
  • For iOS, only mp4 and mov video file formats are supported.

Sample code

DSL

copy
my.saveVideoToPhotosAlbum({
  filePath:'https://resource/apml953bb093ebd2834530196f50a*****.video',
  showActionSheet:true,
  showLoading:true,
  success: (res) => {
    my.alert({ title: 'saveVideo  Success', content: JSON.stringify(res) })
  },
  fail: (res) => {
    my.alert({ title: 'saveVideo  Fail', content: JSON.stringify(res) })
  }
})

H5+

copy
AlipayJSBridge.call('saveVideoToPhotosAlbum', {
        filePath: 'https://resource/apml953bb093ebd2834530196f50a44*****.video',
        showLoading: true,
        showActionSheet: true,
    },
    function(result) {
        alert('Result for saveVideo:' + JSON.stringify(result));
    });

Parameters

Object type with the following attributes:

Property

Type

Required

Description

filePath

String

Yes

Indicates the file path of the video to be saved to the album. It supports network URLs, local temporary files, local cache files, and local user files.

Note: For iOS, only mp4 and mov video file formats are supported.

showActionSheet

Boolean

No

Indicates whether to show the menu when saving the video.

  • true: (Default value) to show the menu.
  • false: not to show the menu.

showLoading

Boolean

No

Indicates whether to show the "Loading" progress when saving the video.

  • true: (Default value) to show the "Loading" progress
  • false: not to show the "Loading" progress

success

Function

No

Callback function upon call success.

fail

Function

No

Callback function upon call failure.

For more, see the following Error code table.

complete

Function

No

Callback function upon call completion (to be executed upon either call success or failure).

Error code

Error code

Error message

Further action

2

Invalid parameter!

The parameter is invalid. Check the filePath parameter and ensure that the parameter is configured correctly.

3

Unknown error!

This error occurs maybe because of the following reasons:

  • This interface does not support parallel calls. Please modify the calling logic to use single (sequential) calls.
  • The file path is not a valid video format. Please provide a video format file path. Check the filePath parameter.
  • Failed to download the network video. Try to download again.

11

User cancelled

N/A

12

Source video file not found.

The source video file does not exist. Check the filePath parameter and ensure that the parameter is configured correctly.

15

No album access rights.

Try to get the album access rights and try to save again.