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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-07-17 09:49:46 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-07-17 09:49:46 +0300
commit3b41b59fcb171b2298cd81b812f0aa2e20f7a9e3 (patch)
tree64537fbacdcaaa0c1e18df6adeaa85a0bdf6ebd2 /README.md
parent6d4c5e3f9def648000747ad882e867e244ef9749 (diff)
doc: simpler examples
Diffstat (limited to 'README.md')
-rw-r--r--README.md24
1 files changed, 7 insertions, 17 deletions
diff --git a/README.md b/README.md
index e65086d..6935ee3 100644
--- a/README.md
+++ b/README.md
@@ -124,20 +124,12 @@ var magnetUri = '...'
client.add(magnetUri, function (torrent) {
// Got torrent metadata!
- console.log('Torrent info hash:', torrent.infoHash)
+ console.log('Client is downloading:', 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)
- })
+ // Display the file by appending it to the DOM. Supports video, audio, images, and
+ // more. Specify a container element (CSS selector or reference to DOM node).
+ file.appendTo('body')
})
})
```
@@ -145,7 +137,7 @@ client.add(magnetUri, function (torrent) {
##### Seeding a file is simple, too:
```js
-var dragDrop = require('drag-drop/buffer')
+var dragDrop = require('drag-drop')
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
@@ -153,8 +145,7 @@ var client = new WebTorrent()
// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', function (files) {
client.seed(files, function onTorrent (torrent) {
- // Client is seeding the file!
- console.log('Torrent info hash:', torrent.infoHash)
+ console.log('Client is seeding:', torrent.infoHash)
})
})
```
@@ -176,8 +167,7 @@ client.add(magnetUri, function (torrent) {
// Stream the video!
// Specify a container element (CSS selector or reference to DOM node)
- file.appendTo('body', function (err, elem) {
- if (err) throw err
+ file.appendTo('body')
})
})
```