Property | Type | Default value | Required | Description |
filePath | string | - | True | The video file path, which can be a temporary file path or a permanent file path. |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.saveVideoToPhotosAlbum({filePath: 'wxfile://xxx',success(res) {console.log(res.errMsg)},})
Property | Type | Default value | Required | Description |
sourceType | Array.<string> | ['album', 'camera'] | False | The source options for video selection. |
compressed | Boolean | true | False | Whether to compress the selected video file. |
maxDuration | number | 60 | False | Maximum recording time for the video, in seconds. |
camera | string | 'back' | False | Default camera to open (front or rear). May not work on some Android devices due to system ROM limitations. |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Value | Description |
album | Selects a video from the album. |
camera | Records a video using the camera. |
Value | Description |
back | Opens the rear camera by default. |
front | Opens the front camera by default. |
Property | Type | Description |
tempFilePath | string | The temporary file path of the selected video. |
duration | number | The selected video duration in seconds. |
size | number | The size of the selected video file, in bytes. |
height | number | The height of the selected video. |
width | number | The width of the selected video. |
wx.chooseVideo({sourceType: ['album', 'camera'],maxDuration: 60,camera: 'back',success(res) {console.log(res.tempFilePath)},})
quality . For more precise control, you can also specify bitrate, fps, and resolution.If quality is provided, these three parameters will be ignored.Property | Type | Required | Description |
src | string | True | The video file path, which can be a temporary file path or a permanent file path. |
quality | string | True | Compression quality. Valid values: low: Low medium: Medium high: High |
bitrate | number | True | Bitrate in kbps. |
fps | number | True | Frame rate. |
resolution. | number | True | The resolution ratio relative to the original video. Value range: (0, 1]. |
success | function | False | Callback function for successful API calls. |
fail | function | False | Callback function for failed API calls. |
complete | function | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
tempFilePath | string | The temporary file path of the compressed video. |
size | string | The size of the compressed video, in KB. |
Property | Type | Default value | Required | Description |
count | number | 15 | False | Maximum number of files that can be selected, up to 15 files. |
mediaType | Array.<string> | ['image','video'] | False | File type. Valid values: image: Only allows taking photos or selecting photos from the album video: Only allows recording videos or selecting videos from the album Note: On iOS, any image format supported by the system photo app can be selected. Typically including JPG, PNG, HEIC (depending on device model and iOS version), and GIF. |
sourceType | Array.<string> | ['album', 'camera'] | False | Source for selecting images and videos. Valid values: album: Selects from the album camera: Takes/records using the camera |
maxDuration | number | 10 | False | Maximum recording time for videos, in seconds. The time range is between 3s and 60s. Videos selected from the album have no duration limit. |
sizeType | Array.<string> | ['original', 'compressed'] | False | Effective only when mediaType is image. Indicates whether to compress the selected files. |
camera | string | 'back' | False | Effective only when sourceType is camera. Specifies whether to use the front or rear camera. back: Uses the rear camera front: Uses the front camera |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
tempFiles | Array.<Object> | List of local temporary files. |
type | string | File type. Valid values: image, video. |
Structural property | Type | Description |
tempFilePath | string | Local temporary file path (local directory). |
size | number | Size of the local temporary file in bytes. |
duration | number | Video duration. |
height | number | Video height. |
width | number | Video width. |
thumbTempFilePath | string | Temporary file path for video thumbnail. |
fileType | string | File type. Valid values: image: Image video: Video |
wx.chooseMedia({count: 9,mediaType: ['image','video'],sourceType: ['album', 'camera'],maxDuration: 30,camera: 'back',success(res) {console.log(res.tempFiles.tempFilePath)console.log(res.tempFiles.size)}})
<view class="section tc"><videoid="myVideo"src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"enable-danmudanmu-btncontrols></video><view class="btn-area"><input bindblur="bindInputBlur" /><button bindtap="bindSendDanmu">Send on-screen comments</button></view></view>
function getRandomColor() {const rgb = []for (let i = 0; i < 3; ++i) {let color = Math.floor(Math.random() * 256).toString(16)color = color.length == 1 ? '0' + color : colorrgb.push(color)}return '#' + rgb.join('')}Page({onReady(res) {this.videoContext = wx.createVideoContext('myVideo')},inputValue: '',bindInputBlur(e) {this.inputValue = e.detail.value},bindSendDanmu() {this.videoContext.sendDanmu({text: this.inputValue,color: getRandomColor(),})},})
Property | Type | Default value | Required | Description |
direction | number | - | False | Set the video orientation in full screen; if not specified, it will be automatically determined based on the aspect ratio. |
Value | Description |
0 | Normal portrait orientation. |
90 | Screen rotated 90 degrees counterclockwise. |
-90 | Screen rotated 90 degrees clockwise. |
Property | Type | Default value | Required | Description |
text | string | - | True | On-screen comment text. |
color | string | - | False | On-screen comment color. |
Feedback