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

Streaming video example #205

Merged
merged 1 commit into from Dec 14, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Streaming video example

Copied straight from #144
  • Loading branch information
TehShrike committed Dec 14, 2014
commit 04ec598159909e9bce1e08fc9c99b3cadb889d00
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.