This API is used via wx.saveVideoToPhotosAlbum(Object object).
Attribute | Type | Default value | Required | Description |
filePath | string | - | Yes | The path of the video file, which can either be a temporary file path or a permanent file path. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.saveVideoToPhotosAlbum({filePath: 'wxfile://xxx',success(res) {console.log(res.errMsg)},})
This API is used via VideoContext wx.createVideoContext(string id, Object this).
This API is used via wx.chooseVideo(Object object).
Attribute | Type | Default value | Required | Description |
sourceType | Array.\\<string> | ['album', 'camera'] | No | Video Selection Source |
compressed | boolean | true | No | Whether to compress the selected video file |
maxDuration | number | 60 | No | Maximum recording time of video, in seconds. |
camera | string | ‘back’ | No | The default is to activate the front or rear camera. However, on some Android phones, this may not work because the system ROM does not support this feature. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Value | Description |
album | Select video from the album |
camera | Capture video using the camera |
Value | Description |
back | Default to activating the rear camera. |
front | Default to activating the front camera. |
Attribute | Type | Description |
tempFilePath | string | Temporary file path of the selected video. |
duration | number | Duration of the selected video. |
size | number | Data size of the selected video. |
height | number | Return to selecting the height of the selected video. |
width | number | Return to selecting the width of the selected video. |
wx.chooseVideo({sourceType: ['album', 'camera'],maxDuration: 60,camera: 'back',success(res) {console.log(res.tempFilePath)},})
This API is used via wx.compressVideo(Object object).
Attribute | Type | Required | Description |
src | string | Yes | The path of the video file, which can either be a temporary file path or a permanent file path. |
quality | string | Yes | Compression quality, whose valid values are: Low: Low power Medium: Moderate power High: High power |
bitrate | number | Yes | Bitrate, measured in kbps. |
fps | number | Yes | Frame rate |
resolution | number | Yes | Resolution ratio relative to the original video, with the value range of (0, 1]. |
success | function | No | Callback Function of Successful Interface Call |
fail | function | No | Callback Function of Failing Interface Call |
complete | function | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
tempFilePath | string | Address of the temporary file after compression. |
size | string | Size after compression, measured in kB. |
This method is used via wx.chooseMedia(Object object).
Attribute | Type | Default value | Required | Description |
count | number | 9 | No | Number of files that can be selected, supports up to 15 files |
mediaType | Array.<string> | ['image','video'] | No | File type, whose valid values are: Image: Only capture images or select images from the album. Video: Only capture videos or select videos from the album. |
sourceType | Array.<string> | ['album', 'camera'] | No | The source of image and video selection, whose valid values are: Album: Select from album Camera: Uses the camera for photographing |
maxDuration | number | 10 | No | Maximum recording time for shooting video, in seconds. The time range is between 3s and 60s. There is no limit to albums. |
sizeType | Array.<string> | ['original', 'compressed'] | No | Only available when mediaType is image, whether to compress the selected file or not. |
camera | string | 'back' | No | Only valid when sourceType is camera, use front or back camera, legal value is: back: use rear camera front: use front camera |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
tempFiles | Array.<Object> | List of local temporary files |
type | string | File type, whose valid values include image, video |
Structure attributes | Type | Description |
tempFilePath | string | Local temporary file path (local direct) |
size | number | Size of local temporary files, measured in bytes. |
duration | number | Duration of video |
height | number | Video height |
width | number | Video width |
fileType | string | File type, whose valid values are: Image 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">Dispatch the barrage</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(),})},})
This method is used via VideoContext.exitFullScreen().
This method is used via VideoContext.exitBackgroundPlayback().
This method is used via VideoContext.hideStatusBar().
This method is used via
This method is used via
This method is used via VideoContext.requestFullScreen(Object object).
Attribute | Type | Default value | Required | Description |
direction | number | - | No | Sets the orientation of the video in full screen mode. If not specified, it will be automatically determined based on the aspect ratio. |
Value | Description |
0 | Normal vertical orientation |
90 | Screen rotating 90 degrees counterclockwise |
-90 | Screen rotating 90 degrees clockwise |
This method is used via VideoContext.requestBackgroundPlayback().
This method is used via VideoContext.seek(number position).
This method is used via VideoContext.sendDanmu(Object data).
Attribute | Type | Default value | Required | Description |
text | string | - | Yes | Barrage text |
color | string | - | No | Barrage color |
This method is used via VideoContext.showStatusBar().
This method is used via VideoContext.stop().