summaryrefslogtreecommitdiffstats
path: root/templates/video-player.html
blob: fd508a8c4b656d4225dbcfe99f6ea62f157ae26d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
<video id="media-$id$" class="thumbnail" controls preload="metadata"></video>
<script type='module'>
  const torrentId = '$torrent$';
  const player = document.querySelector('#media-$id$');
  window.torrentClient.add(torrentId, torrent => {
    const thumbnail = torrent.files.find(file => file.name.endsWith('.jpg')).streamURL;
    player.setAttribute("poster", thumbnail);
    const videofile = torrent.files.find(file => file.name.endsWith('.mp4'));
    videofile.streamTo(player);
  });
</script>