<cloud-player
class="video"
appid="{{appid}}"
fileid="{{fileid}}"
playurl="{{playurl}}"
playerid="myVideo"
class="video"
width="750rpx"
height="428rpx">
<view
wx:if="{{coverShow}}"
class="my_video_cover"
catchtap="handleTapPlay">
</view>
</cloud-player>
Component({
properties: {
fileid: String,
playurl: String,
},
data: {
appid: 'xxxxxxxxx',
coverShow: true,
},
observers: {
'playurl': function(src) {
if(src) {
this.videoContext = wx.createVideoContext('myVideo', this)
}
}
},
methods: {
handleTapPlay(){
console.log(this.videoContext)
this.setData({
coverShow: false
})
setTimeout(_ => {
console.log('调用播放')
this.videoContext.play()
}, 200)
},
}
})
同样无效,没人回答吗
同样无法控制播放
同样,无效;不能操作播放及暂停
import { View, Button } from '@tarojs/components'
import React , {useEffect} from 'react'
import './index.scss'
export default () => {
let videoContext: any;
let myWorld: any;
const play = (): void => {
if(!myWorld) {
myWorld = videoContext.getContext('videooo')
}
myWorld.play()
}
const stop = (): void => {
if(!myWorld) {
myWorld = videoContext.getContext('videooo')
}
myWorld.pause()
}
useEffect(() => {
// 获取插件实例
videoContext = requirePlugin('myPlugin')
myWorld = videoContext.getContext('videooo')
}, [])
return <View>
<View>
<my-player width='100vw' height='33vh' controls appid="1253158205" fileid="5285890814434173294" playerid="videooo"></my-player>
</View>
<View>
<Button onClick={play}>播放</Button>
<Button onClick={stop}>停止</Button>
</View>
</View>
}