- 下载资源先:
https://cloud.baidu.com/doc/Developer/index.html 点击上面的链接,然后滚动到底部,然后在这下载此sdk - 解压以下文件出来放到public文件夹中的play文件夹
- 在index.html引入对应的资源,如图:
- 然后我直接封装了组件形式了,到时候你使用props传参数进来就好了,直接贴代码了。
<template>
<div class="Bvideo">
<div :id="objVideoData.id" class="playercontainer"></div>
</div>
</template>
<script>
export default {
props:{
objVideoData:{
type:Object,
default:function(){
return {}
}
}
},
data(){
return {
player:null,
}
},
mounted() {
this.getVideoFn();
},
methods:{
getVideoFn(){
this.player = cyberplayer(this.objVideoData.idName).setup({
width: '100%',
height: '100%',
title: "",
isLive: true,
file: this.objVideoData.url,
image: 'http://cyberplayer.bcelive.com/thumbnail.jpg',
autostart: true,
stretching: "uniform",
repeat: false,
volume: 0,
controls: true,
starttime: 0,
hls: {
reconnecttime: 8
},
ak: "306985be4a9b4***"
});
}
},
watch:{
objVideoData(newVal,oldVal){
if(newVal){
this.getVideoFn();
}
}
},
destroyed(){
this.player.pause();
this.player.remove();
}
}
</script>
<style lang="less" scoped>
.Bvideo{
width: 100%;
height:100%;
}
</style>
官方的demo:demo
|