Shoot or select pictures or videos from your phone album.
Note
- iOS SDK Version required 1.0.18
- Android SDK Version required 1.0.10
- Before using this interface capability, you need to check the WeChat Developer Tool
project.miniapp.json
Check inMedia SDK
- Before using this interface capability, you need to check the WeChat Developer Tool
project.miniapp.json
In ConfigurationPrivacy Issue Information Access Permission DescriptionLicense descriptions for the album read, camera, and microphone. That is, the interface needs to obtain album reading, camera and microphone permissions before it can be invoked.
- Added: If Android of targetsdkversion Matched 33 And above are required in project.miniapp.json Add the following three permission descriptions (if your developer tools do not have the following three configurations after opening, please upgrade the developer tools to the latest version) nightly Edition)
parameter
Object object
| attribute | type | Default value | Required | Introductions |
| count | number | 9 | no | The maximum number of files that can be selected, up to 9 files before 2.25.0 and up to 20 files after 2.25.0 |
| mediaType | Array.< string> | ['image', 'video'] | no | File type |
| Legal value | Introductions | image | Can only take pictures or select pictures from the album | video | Only shoot videos or select videos from albums | mix | Video and pictures can appear, but not both. |
|
| sourceType | Array.< string> | ['album', 'camera'] | no | The source of the picture and video selection |
| Legal value | Introductions | album | Select from the album | Camera | Shooting with a Camera |
|
| maxDuration | number | 10 | no | Maximum video capture time in seconds. The time frame is 3s to 60s Between. Do not limit the album. |
| sizeType | Array.< string> | ['original', 'compressed'] | no | Whether to compress the selected file, only for mediaType for image Effective when |
| Camera | string | 'back' | no | Only in sourceType for Camera Take effect when using the front or rear camera |
| Legal value | Introductions | back | Use the rear camera | front | Use the front camera |
|
| success | function | | no | Interface calls a successful callback function |
| fail | function | | no | Interface to call a failed callback function |
| complete | function | | no | The callback function at the end of the interface call (the call is executed on success or failure) |
object.success callback
parameter
Object res
| attribute | type | Introductions |
| tempFiles | Array.< Object> | Local Temporary File List |
| | Structural properties | type | Introductions | | tempFilePath | string | Local Temporary File Path (Local path ) | | Size | number | Local Temporary File Size, Unit B | | duration | number | The length of the video | | height | number | The height of the video | | width | number | The width of the video | | thumbTempFilePath | string | Video Thumbnail Temporary File Path | | fileType | string | File type | | Legal value | Introductions | image | picture | video | video |
|
|
| type | string | File type, the valid values have image 、video、mix |
sample code