import{_ as a,c as l,o as p,x as s,a as n,U as o}from"./chunks/framework.75837252.js";const h=JSON.parse('{"title":"webtorrent.js","description":"","frontmatter":{},"headers":[],"relativePath":"library/webtorrent.md","lastUpdated":1676820444000}'),e={name:"library/webtorrent.md"},r=s("h1",{id:"webtorrent-js",tabindex:"-1"},[n("webtorrent.js "),s("a",{class:"header-anchor",href:"#webtorrent-js","aria-label":'Permalink to "webtorrent.js"'},"​")],-1),t=s("p",null,[n("👉 "),s("a",{href:"https://github.com/webtorrent/webtorrent",target:"_blank",rel:"noreferrer"},"https://github.com/webtorrent/webtorrent")],-1),c=s("div",{className:"run-code","data-libs":"https://cdn.jsdelivr.net/npm/webtorrent@2.0.13/index.min.js"}," ▶ Run Code ",-1),F=o(`
js
function playTorrent(video, url, art) {
    const torrent = new WebTorrent();
    torrent.add(url, function (torrent) {
        var file = torrent.files[0];
        file.renderTo(video, {
            autoplay: art.option.autoplay,
        });
    });

    // optional
    art.torrent = torrent;
    art.once('url', () => torrent.destroy());
    art.once('destroy', () => torrent.destroy());
}

var art = new Artplayer({
    container: '.artplayer-app',
    url: 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4',
    type: 'torrent',
    customType: {
        torrent: playTorrent,
    },
});

art.on('ready', () => {
    art.video.controls = false;
    console.info(art.torrent);
});
`,1),y=[r,t,c,F];function D(A,i,C,b,d,m){return p(),l("div",null,y)}const _=a(e,[["render",D]]);export{h as __pageData,_ as default};