How to use the webtorrent/webtorrent.min function in webtorrent

To help you get started, we’ve selected a few webtorrent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qqdaiyu55 / YanQi / src / client / containers / Video.js View on Github external
import React from 'react'
import WebTorrent from 'webtorrent/webtorrent.min'
import Auth from '../modules/Auth'
import { formatVideoTime, BytestoSize, uuidv8 } from '../modules/Library'

var torrentID = ''
var playlist = []
// Disable DHT
var client = new WebTorrent({
  dht: false
})

// Announces list
// global.WEBTORRENT_ANNOUNCE = [
//   'ws://localhost:6969'
// ]

// Display webtorrent video
var displayVideo = (props) => {
  // Show overlay
  $('#video-components .fs-overlay').css({ 'visibility': 'visible', 'opacity': '1', 'width': '100vw', 'height': '100vh' })
  $('#video-topbar .title').html(props.title)

  // Reset loader
  $('#video-loader .loader-inner').show()
github Gargron / cobalt / app / assets / javascripts / webtorrent.js View on Github external
import WebTorrent from 'webtorrent/webtorrent.min';

const client = new WebTorrent();

client.on('error', err => console.error(err));

const torrents = {};

export const addTorrent = url => {
  if (torrents[url]) {
    return torrents[url];
  }

  torrents[url] = client.add(url);

  return torrents[url];
};

export default client;
github qqdaiyu55 / YanQi / src / client / containers / Video.js View on Github external
var setPeerId = (peerId) => {
  client.destroy()
  client = new WebTorrent({
    peerId: peerId,
    dht: false
  })
}
github rllola / zeroTube / app / webtorrent / reducer.js View on Github external
import { UPDATE_INFO } from './constants'
import Webtorrent from 'webtorrent/webtorrent.min'
import rtcConfig from '../../rtcConfig.json'

const initialState = {
  client: new Webtorrent({
    tracker: {
      rtcConfig: rtcConfig
    }
  })
}

export default function webtorrent (state = initialState, action) {
  switch (action.type) {
    case UPDATE_INFO:
      return state
    default:
      return state
  }
}