# 引入首页播放器
<script src="https://activity.hdslb.com/blackboard/static/edfd7948d5ca04de779233922773e479/home-player.min.js"></script>
<script src="https://activity.hdslb.com/blackboard/static/edfd7948d5ca04de779233922773e479/home-player.min.css"></script>
<script>
const el = document.createElement('div')
el.style.cssText = `
width: 700px;
height: 400px;
`
const opts = {
cid: 7734200, // 房间号
rnd: Date.now() / 1000, // 随机数,用于标识用户
}
document.body.append(el)
let player = null
initPlayer(el, opts)
function initPlayer (el, opts) {
if (player){
player.destroy()
player = null
}
player = new window.HomePlayer(el, opts)
player.on('enterTheRoom', ({ cid, type}) => {
console.log(
cid, // 房间号
type // 默认是0
)
})
}
// 用于首页卡片播放器
HomePlayer.fMp4Player(new MediaSource(), document.createElement('video'))
// 断流
player.stop()
// 销毁播放器
player.destroy()
</script>
# API文档
player第二个参数点击查看
playerAPI文档点击查看