首先你需要通过官网的方式解压出来xgplayer
的诸多内置样式,(详情见笔者的这片博客:xgplayer如何自定义样式)
然后再在你解压出来的内容中找到这个文件 loading.js 在/skin/controls/loading.js
这个路径下
import { createDom } from 'xgplayer/src/utils/util'
import Loading from '../assets/loading.svg'
import '../style/controls/loading.scss'
let s_loading = function () {
let player = this
let root = player.root
let container = createDom('xg-loading', `${Loading}`, {}, 'xgplayer-loading') // 创建一个loading 样式内容
console.log(player)
player.once('ready', () => {
root.appendChild(container)
if (player.config.poster) { // 直播封面图片
let dom = document.getElementsByClassName('xgplayer-enter')[0]
dom.style.backgroundImage = `url(${player.config.poster})`
dom.style.backgroundSize = 'cover'
dom.style.backgroundPosition = 'center center'
}
})
}
export default {
name: 's_loading',
method: s_loading
}