this.audio_dp = uni.createInnerAudioContext()
const hls = new Hls()
hls.loadSource('直播音频.m3u8')
hls.attachMedia(this.audio_dp)
hls.on(Hls.Events.MANIFEST_PARSED, () => {
console.log('can-play')
this.audio_dp.play()
})
原生H5里使用audio标签是可以配合hls.js播放m3u8直播音频流的
原生:
<script src="https://cdn.bootcdn.net/ajax/libs/hls.js/1.4.0/hls.js"></script>
<audio id="audio" autoplay src=""></audio>
<button onclick="play()">播放</button>
<script>
const audio = document.getElementById('audio')
window.onload = () => {
console.log('hls', Hls, Hls.Events)
const hls = new Hls()
hls.loadSource('直播音频.m3u8')
hls.attachMedia(audio)
hls.on(Hls.Events.MANIFEST_PARSED, () => {
console.log('can-play')
// audio.play()
})
}
function play() {
audio.play()
}
</script>
0 个回复