https://github.com/feross/webtorrent
JavaScript在浏览器中流以下洪流
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>但这不管用。
发布于 2016-03-26 13:03:53
您发布的代码在web浏览器中不起作用,因为WebTorrent不支持web浏览器环境中的无轨磁铁URI(至少此时如此)。
只需在磁铁URI中添加至少一个WebRTC跟踪器,例如wss://tracker.webtorrent.io
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&tr=wss%3A%2F%2Ftracker.webtorrent.io'或者对*.torrent文件使用HTTP(S) URL:
var torrentId = 'https://webtorrent.io/torrents/sintel.torrent'https://stackoverflow.com/questions/34082637
复制相似问题