Welcome to mirror list, hosted at ThFree Co, Russian Federation.

browser-stream-to-audio.js « examples - github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 01c6499ed1587820a5856ef4a9492e764916f3ec (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 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)
})