valor/layouts/shortcodes/webtorrent-video.html

37 lines
1,022 B
HTML
Raw Normal View History

2022-10-07 23:03:09 -04:00
<style>
#wtmedia{
width:100%;
}
#wtmedia video{
width:100%;
}
</style>
2022-08-17 14:47:54 -04:00
<script src="/webtorrent.js"></script>
2022-10-07 23:03:09 -04:00
<div class="webtorrent">
<noscript>
<video controls>
<source src={{.Get "source"}}>
</video>
</noscript>
<div id="wtmedia">
</div>
<div>
Peers:<span id="Peers"></span>
</div>
2022-08-17 14:47:54 -04:00
</div>
<script>
2022-10-07 23:03:09 -04:00
const client = new WebTorrent();
const magnetURI = {{.Get "magnet"}};
2022-08-17 14:47:54 -04:00
client.add(magnetURI, function (torrent) {
// Got torrent metadata!
2022-10-07 23:03:09 -04:00
torrent.addWebSeed({{.Get "source"}});
console.log('Client is downloading:', torrent.infoHash);
2022-08-17 14:47:54 -04:00
torrent.files.forEach(function (file) {
// Display the file by appending it to the DOM. Supports video, audio, images, and
// more. Specify a container element (CSS selector or reference to DOM node).
2022-10-07 23:03:09 -04:00
file.appendTo('#wtmedia');
2022-08-17 14:47:54 -04:00
})
2022-10-07 23:03:09 -04:00
});
function updateData(torrent);
window.setInterval()
</script>