blob: 84dfdfd3ef52a62489eb46e449fd0a1d65f74e91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
client.add(magnet_uri, function (torrent) {
// Got torrent metadata!
console.log('Torrent info hash:', torrent.infoHash)
// Let's say the first file is an mp3 audio file
var file = torrent.files[0]
// Create an audio element
var audio = document.createElement('audio')
audio.controls = true
document.body.appendChild(audio)
// Stream the audio into the audio tag
file.createReadStream().pipe(audio)
})
|