This code is the code on their website that downloads torrents
const WebTorrent = require('webtorrent')
const client = new WebTorrent()
// Sintel, a free, Creative Commons movie
const torrentId = 'magnet:?'
client.add(torrentId, function (torrent) {
// Torrents can contain many files. Let's use the .mp4 file
const file = torrent.files.find(function (file) {
return file.name.endsWith('.mp4')
})
// Display the file by adding it to the DOM.
// Supports video, audio, image files, and more!
file.appendTo('body')
})
Below this code is says
Video and audio content can be streamed, i.e. playback will start before the full file is downloaded. Seeking works too – WebTorrent dynamically fetches the needed torrent pieces from the network on-demand.
I have searched the internet and not found a way to implement this streaming to video tag feature. Does anyone know how to do this?
From their docs, use this method
file.renderTo('#video')