html
<div class="prism-player" id="J_prismPlayer"></div>
javascript
created() {
function loadScriptString(src) {
var script = document.createElement('script')
script.type = 'text/javascript'
script.src = src
document.getElementsByTagName('head')[0].appendChild(script)
}
function loadLinkString(src) {
var link = document.createElement('link')
link.rel = 'stylesheet'
link.href = src
document.getElementsByTagName('head')[0].appendChild(link)
}
loadLinkString('https://g.alicdn.com/de/prismplayer/2.8.7/skins/default/aliplayer-min.css')
loadScriptString('https://g.alicdn.com/de/prismplayer/2.8.7/aliplayer-min.js')
this.getLive()
},
methods: {
getLive(){
var player = new Aliplayer(
{
id: 'J_prismPlayer',
width: '100%',
height: '200px',
autoplay: true,
source: 'https://xxxx.com/xxx/xx.flv?auth_key=15978868453423f',
isLive: true
},
function(player) {
console.log('播放器创建好了。')
}
)
}
}
注意:uni-app中用组件的方式引入.vue文件是没有onLoad/onShow等生命周期的。
播放器可参考阿里云文档
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)