May 18, 2021 WeChat Mini Program Development Document
VideoContext instance, available at wx.createVideoContext.
VideoContext binds to a video component via id, operating the corresponding video component.
Base library 1.4.0 starts to be supported, and low versions need to be compatible.
Exit full screen
Exit the window, which can be called on any page
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.1.0 starts to support, and low versions need to be compatible.
Hide the status bar, valid only at iOS full screen
Pause the video
Play the video
Base library 1.4.0 starts to be supported, and low versions need to be compatible.
Set up multiple playback
The magnification, support 0.5 / 0.8 / 1.0 / 1.25 / 1.5, 2.6.3 support 2.0 times the speed
The base library 1.4.0 began support, the low version needs to be compatible.
Enter the full screen.If there is a custom content, you need to display the content node to the VIDEO node.
Attributes | type | Defaults | Required | illustrate | Minimum version |
---|---|---|---|---|---|
direction | number | Whether | Set the orientation of the video at full screen, and if you don't specify it, you're automatically judging based on the aspect ratio. | 1.7.0 |
The legal value of object.direction
Value | Description | The lowest version |
---|---|---|
0 | Normal vertical | |
90 | The screen is 90 degrees counterclockwise | |
-90 | The screen is clockwise 90 degrees |
Jump to the specified location
Jump to the location, unit s
Send the impeachment screen
Impeachment content
Property | Type | The default | Required | Description |
---|---|---|---|---|
text | string | Is | Impeachment text | |
color | string | Whether | Impeachment color |
Base library 2.1.0 starts to support, and low versions need to be compatible.
Displays the status bar, valid only at iOS full screen
Base library 1.7.0 starts to support, and low versions need to be compatible.
Stop the video
Preview the effect in the developer tool
<view class="section tc">
<video id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" rel="external nofollow" enable-danmu danmu-btn controls></video>
<view class="btn-area">
<input bindblur="bindInputBlur"/>
<button bindtap="bindSendDanmu">发送弹幕</button>
</view>
</view>
function getRandomColor () {
let rgb = []
for (let i = 0 ; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16)
color = color.length == 1 ? '0' + color : color
rgb.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()
})
}
})