Open qianglu1989 opened 4 years ago
老哥你解决的了吗,我最近也被这个问题困扰着
https://github.com/videojs/video.js/issues/6820 https://github.com/videojs/video.js/issues/7159
videojs并没有这个参数,但是可以通过获取video来设置srcObject
player.tech().el().srcObject = mediaStream
vue-video-player内有一个ready事件,内部参数是this
我目前是根据此事件来设置srcObject
<video-player ref="positiveVideoPlayer" :playsinline="true" :options="positivePlayerOptions" @ready="readyVideo($event,positivePlayerOptions)"></video-player>
//视频初始化后赋值srcObject readyVideo(that,option){ that.player().tech().el().srcObject = option.sources[0].srcObject },
positivePlayerOptions = { //playbackRates: [0.5, 1.0, 1.5, 2.0 ], // 播放速度 autoplay: true, // 如果true,浏览器准备好时开始回放。 sources: [{ type: 'video/mp4', srcObject: stream, //需要先赋值一个可播放视频,不然不会触发@ready src: ‘’https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/byted-player-videos/1.0.0/xgplayer-demo-720p.mp4‘’ }], };
BUG REPORT TEMPLATE
Vue.js version and component version
3.1
Reproduction Link
Steps to reproduce
使用摄像头实时获取数据流,想直接赋给video 组件,比如videoElement.srcObject = mediaStream 但发现playerOptions -》 sources 属性只能接受一个src url ,我怎么才能给他赋值一个stream 到这里