Jon Jovi
Jon Jovi

Reputation: 1

how to code so torrent play play video on my web site

i got this script to play torrent streaming media files in my websites browser page if we drag and drop torrent or magnet link it plays media steam but instead of dragging magnet files on torrent player I want to click the torrent file to play it. I don't know what code to add this code creates a torrent player

     ---

     ... <div id="player" class="webtor" />
     <script>
     window.webtor = window.webtor || [];
     window.webtor.push({
        id: 'player',
        magnet: 'magnet:?
     xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F
     %2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F
     %2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org
     %3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F
     %2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F
     %2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F',
        on: function(e) {
            if (e.name == window.webtor.TORRENT_FETCHED) {
                console.log('Torrent fetched!', e.data);
            }
            if (e.name == window.webtor.TORRENT_ERROR) {
                console.log('Torrent error!');
            }
    },
    poster: 'https://via.placeholder.com/150/0000FF/808080?Text=Sintel',
    subtitles: [
            {
                srclang: 'en',
                label: 'test',
    src: 'https://raw.githubusercontent.com/andreyvit/subtitle-tools/master/sample.srt',
            }
        ],
        lang: 'en',
        i18n: {
            en: {
                common: {
                    "prepare to play": "Preparing Video Stream... Please 

        Wait...",
                },
                stat: {
                    "seeding": "Seeding",
                    "waiting": "Client initialization",
                    "waiting for peers": "Waiting for peers",
                    "from": "from",
                   },
                  },
             },
          });
        </script>
        <script src="https://cdn.jsdelivr.net/npm/@webtor/player-sdk-

                     js/dist/index.min.js" charset="utf-8"></script>
    ---

Upvotes: -1

Views: 1483

Answers (1)

pncln
pncln

Reputation: 70

There's actually a web torrent client which has a much easier implementation

Link: https://www.npmjs.com/package/webtorrent

Upvotes: 0

Related Questions