如何使用 webtorrent.io [英] How to use webtorrent.io

查看:24
本文介绍了如何使用 webtorrent.io的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://webtorrent.io

https://github.com/feross/webtorrent

用于流式传输的 JavaScript浏览器中的以下种子

JavaScript to stream the following torrent in the browser

magnet:?xt=urn:btih:6A9759BFFD5C0AF65319979FB7832189F4F3C35D&dn=sintel.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80&tr=udp%3a%2f%2ftracker.internetwarriors.net%3a1337&tr=udp%3a%2f%2ftracker.leechers-paradise.org%3a6969&tr=udp%3a%2f%2ftracker.coppersurfer.tk%3a6969&tr=udp%3a%2f%2fexodus.desync.com%3a6969&tr=wss%3a%2f%2ftracker.webtorrent.io&tr=wss%3a%2f%2ftracker.btorrent.xyz&ws=https%3a%2f%2fwebtorrent.io%2ftorrents%2fsintel-1024-surround.mp4

我想要一个简单的布局

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script>
</head>
<body>
<script type="text/javascript">

var client = new WebTorrent()

var torrentId = 'magnet:?xt=urn:btih:6A9759BFFD5C0AF65319979FB7832189F4F3C35D'

client.add(torrentId, function (torrent) {
  var file = torrent.files[0]
  file.appendTo('body') // append the file to the DOM
})
</script>
</body>
</html>

但这不起作用.

推荐答案

您发布的代码在 Web 浏览器中不起作用,因为 WebTorrent 不支持 Web 浏览器环境中的无跟踪磁体 URI(至少目前是这样).

The code you posted doesn't work in web browser, because WebTorrent doesn't support trackerless magnet URIs in web browser environment (at least at this moment).

只需将至少一个 WebRTC 跟踪器添加到您的磁力 URI,例如wss://tracker.webtorrent.io:

Just add at least one WebRTC tracker to your magnet URI, e.g. wss://tracker.webtorrent.io:

var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&tr=wss%3A%2F%2Ftracker.webtorrent.io'

或使用 HTTP(S) URL 到 *.torrent 文件:

or use HTTP(S) URL to *.torrent file:

var torrentId = 'https://webtorrent.io/torrents/sintel.torrent'

这篇关于如何使用 webtorrent.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆