diff options
author | Joseph Dykstra <josephdykstra@gmail.com> | 2015-01-17 01:45:13 +0300 |
---|---|---|
committer | Joseph Dykstra <josephdykstra@gmail.com> | 2015-01-17 01:45:13 +0300 |
commit | 777d6c2225a5fae5f514a141ea3ec25d97763754 (patch) | |
tree | 88a5d6d433e7ce9c9a0f0c995fbdafbdbf59378e /examples/browser-stream-to-video.js | |
parent | d880b81ff83a860594a5310dd0a05fdb1ca7f876 (diff) |
Added ./examples/ directory
Diffstat (limited to 'examples/browser-stream-to-video.js')
-rw-r--r-- | examples/browser-stream-to-video.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/browser-stream-to-video.js b/examples/browser-stream-to-video.js new file mode 100644 index 0000000..7943a64 --- /dev/null +++ b/examples/browser-stream-to-video.js @@ -0,0 +1,19 @@ +var WebTorrent = require('webtorrent')
+
+var client = new WebTorrent()
+
+client.add(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)
+})
|