本系列各篇章的翻譯連接以下:javascript
譯註:如下斜體文本是原文中的編者按html
WebTorrent is the first torrent client that works in the browser. It’s written completely in JavaScript – the language of the web – and uses WebRTC for true peer-to-peer transport. No browser plugin, extension, or installation is required.java
WebTorrent 是第一款運行在瀏覽器中的 torrent 客戶端。它徹底是用 JavaScript ——也就是 Web 所使用的語言——編寫的,使用的是 WebRTC 來進行真實的點對點傳輸。沒借助瀏覽器插件、擴展,也無需額外安裝其餘東西。node
Using open web standards, WebTorrent connects website users together to form a distributed, decentralized browser-to-browser network for efficient file transfer. The more people use a WebTorrent-powered website, the faster and more resilient it becomes.git
藉助各類開放的 Web 標準,WebTorrent 得以將網站的用戶鏈接到一塊兒,組成一張具有高效文件傳輸能力的「瀏覽器對瀏覽器」的分佈式、去中心化的網絡。一個基於 WebTorrent 的網站,其使用的人越多,它的速度就越快,可復原性也越強。web
The WebTorrent protocol works just like BitTorrent protocol, except it uses WebRTC instead of TCP or uTP as the transport protocol.express
WebTorrent 協議的工做機制和 BitTorrent 協議同樣,除了它使用的是 WebRTC 而不是 TCP 或者 uTP 做爲傳輸協議外。npm
In order to support WebRTC’s connection model, we made a few changes to the tracker protocol. Therefore, a browser-based WebTorrent client or 「web peer」 can only connect to other clients that support WebTorrent/WebRTC.瀏覽器
爲了能支持 WebRTC 的鏈接模型,咱們對(torrent 的) tracker 協議作了一些修改。這樣,一個基於瀏覽器的 WebTorrent 客戶端——或者說是 「web peer」—— 就能夠與其餘支持 WebTorrent 及 WebRTC 的客戶端創建鏈接。bash
Once peers are connected, the wire protocol used to communicate is exactly the same as in normal BitTorrent. This should make it easy for existing popular torrent clients like Transmission, and uTorrent to add support for WebTorrent. Vuze already has support for WebTorrent!
一旦點與點之間創建了鏈接,(基於該鏈接之上的)用於通信的協議就和常規的 BitTorrent 的沒有區別了。這可讓已有的各主流的 torrent 客戶端——如 Transmission、uTorrent——在增長對 WebTorrent 的支持時變得容易。——Vuze 已經實現了對 WebTorrent 的支持!
It only takes a few lines of code to download a torrent in the browser!
在瀏覽器中下載一個 torrent 文件只須要幾行代碼就能夠作到!
To start using WebTorrent, simply include the webtorrent.min.js
script on your page. You can download the script from the WebTorrent website or link to the CDN copy.
要使用 WebTorrent,只需在你的頁面中將 weborrent.min.js
腳本文件引用進來便可。你能夠從 WebTorrent 的網站上下載(這個文件)或者將連接指向到一個 CDN 副本。
<script src="webtorrent.min.js"></script>複製代碼
This provides a WebTorrent
function on the window
object. There is also an npm package available.
這樣以後,它會在 Window 對象上提供一個 WebTorrent 函數(供使用)。此外還有 npm 包 可用。
var client = new WebTorrent()
// Sintel, a free, Creative Commons movie
// 《辛特爾》,一部免費,採用「知識共享」(許可協議)的電影
var torrentId = 'magnet:...' // Real torrent ids are much longer. // 真實的 torrent id 遠比這個長
var torrent = client.add(torrentId)
torrent.on('ready', () => {
// Torrents can contain many files. Let's use the .mp4 file
// 一個種子文件能夠包含許多個文件。這裏咱們只使用 .mp4 文件
var file = torrent.files.find(file => file.name.endsWith('.mp4'))
// Display the file by adding it to the DOM.
// Supports video, audio, image files, and more!
// 把他添加到 DOM 中進行展現。
// 支持視頻、音頻、圖像文件等等!
file.appendTo('body')
})複製代碼
That’s it! Now you’ll see the torrent streaming into a <video width="300" height="150">
tag in the webpage!
就這樣!如今你就能夠在網頁中看到這個 torrent 被灌輸到了 <video width="300" height="150">
標籤中。
You can learn more at webtorrent.io, or by asking a question in #webtorrent on Freenode IRC or on Gitter. We’re looking for more people who can answer questions and help people with issues on the GitHub issue tracker. If you’re a friendly, helpful person and want an excuse to dig deeper into the torrent protocol or WebRTC, then this is your chance!
你能夠在 webtorrent.io 瞭解更多的信息,你也能夠在 Freenode IRC 及 Gitter 上的 #webtorrent (頻道/主題下)發出提問。咱們正期待有更多的人在 GitHub 的問題跟蹤列表上提交和解答問題。若是你是一位友好、樂於助人的人,而且在找機會深刻挖掘 torrent 協議和/或 WebRTC,那麼如今就是機會!
Feross writes popular open source software including WebTorrent, StandardJS, and hundreds of Node.js packages (collectively 200+ million downloads per month). He recently released a fun site called BitMidi that curates MIDI files for your listening pleasure! His open source work is supported by generous donors on Patreon.
Feross 編寫了許多流行的開源軟件的,包括 WebTorrent、StandardJS,以及幾百份的 Node.js 包(每個月總計 2 億屢次的下載量)。最近,他發佈了一個名爲 BitMidi 的有趣的網站,這個網站組織了許多的 MIDI 文件,能夠爲你帶來聽覺享受!他的開源事業都是由 Patreon 上慷慨的捐助者們所支持的。
他的主頁:feross.org
他的Twitter: @feross