<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script type="module" src="/js/webtorrent.js">
  </script>

  <script type="module">
    const wt_opts = {
      use_dht: false,
      private: true,
      tracker: true,
      webSeeds: true,
      maxConns: 50
    }

    let client = new WebTorrent(wt_opts);

    function onTorrent(torrent) {
      console.log(torrent.files);
      const file = torrent.files[0];
      file.renderTo("#video-player");
    }

    client.add("${base_host}${media.torrent_url}", onTorrent);
  </script>

  <title>${ site_name }: ${ media.title }</title>

  <style>
    body {
      margin: 0px;
      padding: 0px;
    }

    video {
      max-width: 100vw;
      min-width: 100vw;
      width: 100vw;
    }
  </style>
</head>

<video id="video-player" poster="${ media.poster }">
</video>

<body>
</body>
</html>