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:
authorJosh Duff <me@JoshDuff.com>2014-12-14 06:51:35 +0300
committerJosh Duff <me@JoshDuff.com>2014-12-14 06:51:35 +0300
commit04ec598159909e9bce1e08fc9c99b3cadb889d00 (patch)
treedc0dbef8b56b13460bc5c4794a1345a12fae6e0c /README.md
parente01cb256922bdfb95162662e48f2d2c1506eaea1 (diff)
Streaming video example
Copied straight from #144
Diffstat (limited to 'README.md')
-rw-r--r--README.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4075c83..1a585b8 100644
--- a/README.md
+++ b/README.md
@@ -135,6 +135,30 @@ dragDrop('body', function (files) {
})
```
+##### Streaming to an HTML5 video element? Also simple!
+
+```js
+var WebTorrent = require('webtorrent')
+
+var client = new WebTorrent()
+
+client.download(magnet_uri, function (torrent) {
+ // Got torrent metadata!
+ console.log('Torrent info hash:', torrent.infoHash)
+
+ // Let's say the first file is a webm (vp8) or mp4 (h264) video...
+ var file = torrent.files[0]
+
+ // Create a video element
+ var video = document.createElement('video')
+ video.controls = true
+ document.body.appendChild(video)
+
+ // Stream the video into the video tag
+ file.createReadStream().pipe(video)
+})
+```
+
##### Browserify
WebTorrent works great with [browserify](http://browserify.org/), an npm module that let's