40 lines
No EOL
1.1 KiB
HTML
40 lines
No EOL
1.1 KiB
HTML
<style>
|
|
#wtmedia{
|
|
width:100%;
|
|
}
|
|
#wtmedia video{
|
|
width:100%;
|
|
}
|
|
</style>
|
|
<script src="/webtorrent.js"></script>
|
|
<div class="webtorrent">
|
|
<noscript>
|
|
<video controls>
|
|
<source src={{.Get "source"}}>
|
|
</video>
|
|
</noscript>
|
|
<div id="wtmedia">
|
|
</div>
|
|
<div>
|
|
Peers:<span id="Peers"></span>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
function updateData(torrent) {
|
|
document.getElementById('Peers').text=torrent.numPeers;
|
|
}
|
|
const client = new WebTorrent();
|
|
const magnetURI = {{.Get "magnet"}};
|
|
client.add(magnetURI, function (torrent) {
|
|
// Got torrent metadata!
|
|
torrent.addWebSeed({{.Get "source"}});
|
|
console.log("Torrent Peers: "+torrent.numPeers);
|
|
console.log('Client is downloading:', torrent.infoHash);
|
|
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).
|
|
file.appendTo('#wtmedia');
|
|
})
|
|
window.setInterval
|
|
});
|
|
</script> |