目录

Media File Access

You can call has.chooseImage to select images and access the media library resources.

has.chooseImage({
  count: 1, // The default value is 9.
  sizeType: ['original', 'compressed'], // Specify whether the image is an original or a compressed one. By default, both are supported.
  sourceType: ['album', 'camera'], // Specify whether the image is chosen from the album or taken using a camera. By default, both are supported.
  success: (res) => {
    console.info('chooseImage success', res);
  }
});

You can call has.chooseVideo to select videos and access the media library resources.

has.chooseVideo({
  sourceType: ['album', 'camera'], // Specify whether the video is chosen from the album or taken using a camera. By default, both are supported.
  maxDuration: 60, // Specify the maximum duration for video recording in seconds. The default value is 60. This parameter takes effect only when sourceType is set to camera.
  camera: 'back', // Specify whether to use the front or rear camera. By default, the rear camera is used. This parameter takes effect only when sourceType is set to camera.
  success: (res) => {
    console.info('chooseVideo success', res);
  }
});

You can also call has.chooseMedia to select images or videos and access the media library resources.

has.chooseMedia({
  count: 2, // The default value is 9.
  mediaType: ['image', 'video'], // Specify whether the file is an image or a video. By default, both are supported.
  sizeType: ['original', 'compressed'], // Specify whether the file is an original or a compressed one. By default, both are supported.
  sourceType: ['album', 'camera'], // Specify whether the image/video is chosen from the album or taken using a camera. By default, both are supported.
  maxDuration: 10, // Specify the maximum duration for video recording in seconds. The default value is 10. This parameter takes effect only when sourceType is set to camera.
  camera: 'back', // Specify whether to use the front or rear camera. By default, the rear camera is used. This parameter takes effect only when sourceType is set to camera.
  success: (res) => {
    console.info('chooseMedia success', res);
  }
});