import{_ as a,c as n,o as l,j as s,a as i,a7 as p}from"./chunks/framework.DXlgpajS.js";const m=JSON.parse('{"title":"hls.js","description":"","frontmatter":{},"headers":[],"relativePath":"library/hls.md","filePath":"library/hls.md","lastUpdated":1682237343000}'),h={name:"library/hls.md"},e=s("h1",{id:"hls-js",tabindex:"-1"},[i("hls.js "),s("a",{class:"header-anchor",href:"#hls-js","aria-label":'Permalink to "hls.js"'},"​")],-1),t=s("p",null,[i("👉 "),s("a",{href:"https://github.com/video-dev/hls.js",target:"_blank",rel:"noreferrer"},"https://github.com/video-dev/hls.js")],-1),k=s("div",{className:"run-code","data-libs":"https://cdnjs.cloudflare.com/ajax/libs/hls.js/8.0.0-beta.3/hls.min.js"}," ▶ Run Code ",-1),r=p(`
js
function playM3u8(video, url, art) {
    if (Hls.isSupported()) {
        if (art.hls) art.hls.destroy();
        const hls = new Hls();
        hls.loadSource(url);
        hls.attachMedia(video);
        art.hls = hls;
        art.on('destroy', () => hls.destroy());
    } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = url;
    } else {
        art.notice.show = 'Unsupported playback format: m3u8';
    }
}

var art = new Artplayer({
    container: '.artplayer-app',
    url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
    type: 'm3u8',
    customType: {
        m3u8: playM3u8,
    },
});

art.on('ready', () => {
    console.info(art.hls);
});
`,1),E=[e,t,k,r];function d(y,c,g,o,b,F){return l(),n("div",null,E)}const _=a(h,[["render",d]]);export{m as __pageData,_ as default};