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>2016-08-04 04:03:31 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-08-04 04:03:31 +0300
commit58cf082cfcba09fa8a129c4181f35df37857af1d (patch)
tree296d43c5e0673d76b6d679b6499c799996c7b9df
parent51ffc85dc3d2390e4594873d2fb1e4e405c30644 (diff)
Add options to disable autoplay/hide controls
Fix #878.
-rw-r--r--docs/api.md14
-rw-r--r--lib/file.js8
-rw-r--r--package.json2
3 files changed, 15 insertions, 9 deletions
diff --git a/docs/api.md b/docs/api.md
index 2ea80d0..5903a67 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -501,7 +501,7 @@ file.getBuffer(function (err, buffer) {
})
```
-## `file.appendTo(rootElem, [function callback (err, elem) {}])` *(browser only)*
+## `file.appendTo(rootElem, [opts], [function callback (err, elem) {}])` *(browser only)*
Show the file in a the browser by appending it to the DOM. This is a powerful function
that handles many file types like video (.mp4, .webm, .m4v, etc.), audio (.m4a, .mp3,
@@ -518,8 +518,14 @@ the file will be downloaded then displayed.
will be shown in. A new DOM node will be created for the content and appended to
`rootElem`.
-`callback` will be called once the file is visible to the user. `callback` is called
-with an `Error` (or `null`) and the new DOM node that is displaying the content.
+If provided, `opts` can contain the following options:
+
+- `autoplay`: Autoplay video/audio files (default: `true`)
+- `controls`: Show video/audio player controls (default: `true`)
+
+If provided, `callback` will be called once the file is visible to the user.
+`callback` is called with an `Error` (or `null`) and the new DOM node that is
+displaying the content.
```js
file.appendTo('#containerElement', function (err, elem) {
@@ -528,7 +534,7 @@ file.appendTo('#containerElement', function (err, elem) {
})
```
-## `file.renderTo(elem, [function callback (err, elem) {}])` *(browser only)*
+## `file.renderTo(elem, [opts], [function callback (err, elem) {}])` *(browser only)*
Like `file.appendTo` but renders directly into given element (or CSS selector).
diff --git a/lib/file.js b/lib/file.js
index 5f8021c..65c9187 100644
--- a/lib/file.js
+++ b/lib/file.js
@@ -85,14 +85,14 @@ File.prototype.getBlobURL = function (cb) {
streamToBlobURL(this.createReadStream(), this._getMimeType(), cb)
}
-File.prototype.appendTo = function (elem, cb) {
+File.prototype.appendTo = function (elem, opts, cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
- render.append(this, elem, cb)
+ render.append(this, elem, opts, cb)
}
-File.prototype.renderTo = function (elem, cb) {
+File.prototype.renderTo = function (elem, opts, cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
- render.render(this, elem, cb)
+ render.render(this, elem, opts, cb)
}
File.prototype._getMimeType = function () {
diff --git a/package.json b/package.json
index 4df034a..ace6ca8 100644
--- a/package.json
+++ b/package.json
@@ -48,7 +48,7 @@
"random-iterate": "^1.0.1",
"range-parser": "^1.2.0",
"readable-stream": "^2.1.4",
- "render-media": "^2.6.0",
+ "render-media": "^2.8.0",
"run-parallel": "^1.1.6",
"run-parallel-limit": "^1.0.3",
"safe-buffer": "^5.0.1",