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

Improve integration instructions #681

Merged
merged 3 commits into from Mar 16, 2016
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

@@ -101,10 +101,6 @@ connect to both normal *and* web peers.

- Stream to **AirPlay**, **Chromecast**, **VLC player**, and many other devices/players

**NOTE**: To connect to "web peers" (browsers) in addition to normal BitTorrent peers, use
[webtorrent-hybrid](https://github.com/feross/webtorrent-hybrid) which includes WebRTC
support for node.

### Install

To install WebTorrent for use in node or the browser with `require('webtorrent')`, run:
@@ -192,6 +188,30 @@ There are more examples in the [examples](https://github.com/feross/webtorrent/t
WebTorrent works great with [browserify](http://browserify.org/), an npm module that let's
you use [node](http://nodejs.org/)-style require() to organize your browser code and load modules installed by [npm](https://www.npmjs.com/) (as seen in the previous examples).

##### Webpack

WebTorrent works also great with [webpack](http://webpack.github.io/), a module bundler similar to browserify that supports various files types. Although webpack uses the specified [browser-field](https://github.com/feross/webtorrent/blob/master/package.json#L10) to reference alternative packages for the browser, following configurations have to be done to bundle the code:
```js
{
target: 'web',
node: {
fs: 'empty'
},
module: {
loaders: [
// requires you to install the 'json-loader' module first: npm install --save-dev json-loader
{
test: /\.json$/,
loader: 'json'
}
]
}
}
```
Otherwise you could also directly use the pre-built version via `require('webtorrent/webtorrent.min')`.

#### Global

WebTorrent is also available as a standalone script
([`webtorrent.min.js`](webtorrent.min.js)) which exposes `WebTorrent` on the `window`
object, so it can be used with just a script tag:
@@ -211,6 +231,10 @@ MaxCDN) for easy inclusion on your site:

WebTorrent also works in node.js, using the *same npm module!* It's mad science!

**NOTE**: To connect to "web peers" (browsers) in addition to normal BitTorrent peers, use
[webtorrent-hybrid](https://github.com/feross/webtorrent-hybrid) which includes WebRTC
support for node.

#### As a command line app

WebTorrent is available as [a command line app](https://github.com/feross/webtorrent-cli).
@@ -279,7 +303,7 @@ If `opts` is specified, then the default options (shown below) will be overridde
peerId: String|Buffer, // Wire protocol peer ID (default=randomly generated)
rtcConfig: Object, // RTCPeerConnection configuration object (default=STUN only)
tracker: Boolean, // Whether or not to enable trackers (default=true)
wrtc: Object // Custom webrtc implementation (in node, specify the [wrtc](https://www.npmjs.com/package/wrtc) package)
wrtc: Object // Custom webrtc implementation (in node, specify the [wrtc](https://www.npmjs.com/package/wrtc) or [electron-webrtc](https://github.com/mappum/electron-webrtc) package)
}
```

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.