I have some idea for WebTorrent. I have some experience with JavaScript and jQuery, but I never use Node.js or Browserify. Could someone explain me how to use the following simple code?
var client = new WebTorrent()
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'
client.add(torrentId, function (torrent) {
// Torrents can contain many files. Let's use the first.
var file = torrent.files[0]
// Display the file by adding it to the DOM. Supports video, audio, image, etc. files
file.appendTo('body')
})
Should I attach a <script src="webtorrent.min.js"></script>
and convert the code from above by Browserify (browserify app.js > bundle.js
)? Or maybe I need to use npm install webtorrent
and attach some Browserify code?
After using the code npm install webtorrent
and just doing Ctrl + c + Ctrl + v, this example from above in <script>
tag showed up player. Magic :) But I do something in my VM and now Chrome say that the require('webtorrent')
is not definied.
It would be great if I could use WebTorrent as simple as jQuery.
<script src="webtorrent.min.js"></script>
), you don't need browserify or require.