blob: e721ceebcc5a894814b851b6d0530d99e38119b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
var magnetUri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
client.add(magnetUri, function (torrent) {
// Got torrent metadata!
console.log('Torrent info hash:', torrent.infoHash)
// Let's say the first file is a webm (vp8) or mp4 (h264) video...
var file = torrent.files[0]
// Create a video element
var video = document.createElement('video')
video.controls = true
document.body.appendChild(video)
// Stream the video into the video tag
file.createReadStream().pipe(video)
})
|