[LayaAir3]LAYAAIR 3.3 和 LAYANATIVE 的VIDEO 支持 M3U8文件吗?

测试了均无法正常播放? 想请问为什么?谢谢
已邀请:

Laya_XS

赞同来自:

在LayaAir里用video播放直播流时,需要借助第三方库才可以。附件提供了第三方库。使用参考代码:
var videoTexture = new Laya.VideoTexture();
var video = videoTexture.video;
var m3u8url = "https://xxxx.m3u8";
var hlsxx;
var HLS = window["Hls"];
if (HLS && HLS.isSupported()) {
var hls = new HLS({
debug: false,
});
hls.loadSource(m3u8url);
hls.attachMedia(video);
hls.on(HLS.Events.MEDIA_ATTACHED, () => {
video.muted = true;
this.playVideo();
});
hls.on(HLS.Events.ERROR, (event, data) => {
console.log("HLS加载失败");
});
hlsxx = hls;//方便销毁用hlsxx.destroy();
}else if(videoTexture.canPlayType("m3u8")){
this.playVideo();
videoTexture.element.pause();
videoTexture.element.src = m3u8url;
videoTexture.element.load();
videoTexture["_video"] = videoTexture.element;
}

function playVideo(){
//这里就做一些video的参数设置,比如静音、循环、播放等设置即可
//video.muted = this._muted;
//video.loop = this._loop;
//video.onended = this._onended;
//video.onclose = this._onclose;
//videoTexture.play();
}
目前直播流使用未在native端测试,是否支持还需要使用者亲自验证下。

要回复问题请先

商务合作
商务合作