diff --git a/packages/artplayer-vitepress/docs/.vitepress/config.js b/packages/artplayer-vitepress/docs/.vitepress/config.js
index af4381772..cea9c1435 100644
--- a/packages/artplayer-vitepress/docs/.vitepress/config.js
+++ b/packages/artplayer-vitepress/docs/.vitepress/config.js
@@ -69,6 +69,7 @@ const config = {
{ text: 'hls.js', link: '/library/hls' },
{ text: 'flv.js', link: '/library/flv' },
{ text: 'dash.js', link: '/library/dash' },
+ { text: 'webtorrent.js', link: '/library/webtorrent' },
]
},
],
@@ -112,6 +113,7 @@ const config = {
{ text: 'hls.js', link: '/en/library/hls' },
{ text: 'flv.js', link: '/en/library/flv' },
{ text: 'dash.js', link: '/en/library/dash' },
+ { text: 'webtorrent.js', link: '/en/library/webtorrent' },
]
},
],
diff --git a/packages/artplayer-vitepress/docs/en/library/webtorrent.md b/packages/artplayer-vitepress/docs/en/library/webtorrent.md
new file mode 100644
index 000000000..a5bcaa3a0
--- /dev/null
+++ b/packages/artplayer-vitepress/docs/en/library/webtorrent.md
@@ -0,0 +1,38 @@
+# webtorrent.js
+
+👉 [https://github.com/webtorrent/webtorrent](https://github.com/webtorrent/webtorrent)
+
+
+ â–¶ Run Code
+
+
+```js{21-24,28}
+function playTorrent(video, url, art) {
+ const torrent = new WebTorrent();
+ torrent.add(url, function (torrent) {
+ var file = torrent.files[0];
+ file.renderTo(video, {
+ autoplay: art.option.autoplay,
+ });
+ });
+
+ // optional
+ art.torrent = torrent;
+ art.once('url', () => torrent.destroy());
+ art.once('destroy', () => torrent.destroy());
+}
+
+var art = new Artplayer({
+ container: '.artplayer-app',
+ url: 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4',
+ type: 'torrent',
+ customType: {
+ torrent: playTorrent,
+ },
+});
+
+art.on('ready', () => {
+ art.video.controls = false;
+ console.info(art.torrent);
+});
+```
\ No newline at end of file
diff --git a/packages/artplayer-vitepress/docs/library/webtorrent.md b/packages/artplayer-vitepress/docs/library/webtorrent.md
new file mode 100644
index 000000000..a5bcaa3a0
--- /dev/null
+++ b/packages/artplayer-vitepress/docs/library/webtorrent.md
@@ -0,0 +1,38 @@
+# webtorrent.js
+
+👉 [https://github.com/webtorrent/webtorrent](https://github.com/webtorrent/webtorrent)
+
+
+ â–¶ Run Code
+
+
+```js{21-24,28}
+function playTorrent(video, url, art) {
+ const torrent = new WebTorrent();
+ torrent.add(url, function (torrent) {
+ var file = torrent.files[0];
+ file.renderTo(video, {
+ autoplay: art.option.autoplay,
+ });
+ });
+
+ // optional
+ art.torrent = torrent;
+ art.once('url', () => torrent.destroy());
+ art.once('destroy', () => torrent.destroy());
+}
+
+var art = new Artplayer({
+ container: '.artplayer-app',
+ url: 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4',
+ type: 'torrent',
+ customType: {
+ torrent: playTorrent,
+ },
+});
+
+art.on('ready', () => {
+ art.video.controls = false;
+ console.info(art.torrent);
+});
+```
\ No newline at end of file