Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid using node.js #279

Closed
charlsagente opened this issue Mar 12, 2015 · 1 comment
Closed

avoid using node.js #279

charlsagente opened this issue Mar 12, 2015 · 1 comment

Comments

@charlsagente
Copy link

@charlsagente charlsagente commented Mar 12, 2015

Hi guys i apologize for the previous issue.
Im trying to use only webtorrent without using node.js. I installed your webtorrent.min.js in my apache server and used in the following example.

But the next code does nothing. What am i doing wrong?
node.js is necessary? or just the browser?

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
      <script src="webtorrent.min.js"></script>
</head>
<body>
 <script>
 var client = new WebTorrent()
var magnetUri = '...'  //copied directly from a torrent

client.add(magnetUri, { tmp: 'C:\Users\lenovo\Downloads' },function (torrent) {
  // Got torrent metadata!
  console.log('Torrent info hash:', torrent.infoHash)

  torrent.files.forEach(function (file) {
    // Get a url for each file
    file.getBlobURL(function (err, url) {
      if (err) throw err

      // Add a link to the page
      var a = document.createElement('a')
      a.download = file.name
      a.href = url
      a.textContent = 'Download ' + file.name
      document.body.appendChild(a)
    })
  })
})
 </script>


</body>
</html>
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Mar 12, 2015

WebTorrent works in the browser without node.js. But you can't just paste in any random magnet uri or .torrent file.

In the browser, WebTorrent can only download torrents that are explicitly seeded to the WebTorrent network. Desktop torrent clients need to support WebRTC to peer with web browsers. Currently, no clients support it but you can use http://instant.io/ to seed torrents to the WebTorrent network.

@feross feross closed this Mar 12, 2015
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.