demo git地址: jessibuca-vue-ts-demo
使用:在index.html里引入静态文件
// jessibuca文件在demo里public下有,考下来直接使用即可
<script src="/jessibuca.js"></script>
demo已封装组件直接引入使用即可src/components/JessibucaDemo.vue文件
引入:
import JessibucaDemo from './component/JessibucaDemo.vue'
// 定义ref获取组件内方法以及定义值
const JessibucaDemoRef = ref<InstanceType<typeof JessibucaDemo>>();
//dom结构里使用
<JessibucaDemo ref="JessibucaDemoRef"/>
获取地址给组件播放地址赋值
// 赋值
JessibucaDemoRef.value.playUrl = res.data.data.url
// 调用播放方法
JessibucaDemoRef.value.play()
//调用暂停播放
JessibucaDemoRef.value.pause()
视频流断开重连:修改demo组件内部方法
// 断开后重新调用播放方法即可
jessibuca.on("timeout", function () {
play()
});