代码拉取完成,页面将自动刷新
<script>
export default {
onLaunch: function() {
// 增加对Android H5播放m3u8支持, 参考:https://segmentfault.com/a/1190000039976865
// #ifdef H5
if (uni.getSystemInfoSync().platform != 'ios') {
var script = document.createElement('script')
script.src = 'https://cdn.staticfile.org/hls.js/1.1.5/hls.min.js'
script.onload = function() {
let init = function(video) {
if (!video.getAttribute('hls-inited')) {
let hls = null
let load = function() {
let src = video.src
if (!src || src.indexOf('.m3u8') < 0) return
if (!hls) {
hls = new Hls()
hls.attachMedia(video)
}
hls.loadSource(src)
}
video.addEventListener('error', function() {
load()
}, false)
video.addEventListener('DOMNodeRemovedFromDocument', function() {
if (hls) hls.destroy()
}, false)
video.setAttribute('hls-inited', 'ok')
}
}
document.body.addEventListener('DOMNodeInserted', function(e) {
let ele = e.relatedNode
let videoObj = ele.getElementsByTagName('video')
if (videoObj.length > 0) {
for (let i = 0; i < videoObj.length; i++) {
init(videoObj[i])
}
}
})
}
var s = document.getElementsByTagName('script')[0]
s.parentNode.insertBefore(script, s)
}
// #endif
},
onShow: function() {
console.log('On Show')
},
onHide: function() {
console.log('On Hide')
},
}
</script>
<style lang="scss">
@import "uview-ui/index.scss";
@import "static/css/common.css";
@import "static/css/content.css";
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。