正文
flvjs的unload(),detachMediaElement(),destroy()报错,undefined,not a function解决方案
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
首先,真的被网上一堆各种转载复制粘贴坑了不少,最后直接到GitHub上flvjs的看作者的demo和docs才解决,具体如下。
1.引入flvjs文件,新建实例
var flvUrl = '直播流地址'
var flvPlayer=null//flv实例
if (flvjs.isSupported()) {
flvPlayer = flvjs.createPlayer({
type: 'flv',
url: flvUrl
})
flvPlayer.attachMediaElement("播放视频用的video标签")
flvPlayer.load()
flvPlayer.play()
}
2.停止混流播放并移除直播流抓取
function pausemix() {
flvPlayer.pause()
flvPlayer.unload()
flvPlayer.detachMediaElement()
flvPlayer.destroy()
flvPlayer = null
},
flvPlayer为之前新建的flv实例
3.停止flvjs的控制台输出(⊙﹏⊙)这个还在折腾中,想项目折腾出来再优化