Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Azuinphp

https://webtorrent.io/ adaptar a phpost v6 de tronlar

Recommended Posts

No sabria si pedirlo de rodillas pero este complemente lograria revivir a phpost no lo veo muy dificil lo eh intentado pero no lo consegui estoy en udemy para tratar de aprender php 7 si alguien por faor podria adaptarlo.

Hacer streaming directo colocando    tuweb.com/archivo/movie.torrent
de echo funciona de esa manera aki unas lineas en html 

 

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>WebTorrent video player</title>
    <style>
      #output video {
        width: 100%;
      }
      #progressBar {
          height: 5px;
          width: 0%;
          background-color: #35b44f;
          transition: width .4s ease-in-out;
      }
      body.is-seed .show-seed {
          display: inline;
      }
      body.is-seed .show-leech {
          display: none;
      }
      .show-seed {
          display: none;
      }
      #status code {
          font-size: 90%;
          font-weight: 700;
          margin-left: 3px;
          margin-right: 3px;
          border-bottom: 1px dashed rgba(255,255,255,0.3);
      }

      .is-seed #hero {
          background-color: #154820;
          transition: .5s .5s background-color ease-in-out;
      }
      #hero {
          background-color: #2a3749;
      }
      #status {
          color: #fff;
          font-size: 17px;
          padding: 5px;
      }
      a:link, a:visited {
          color: #30a247;
          text-decoration: none;
      }
    </style>
  </head>
  <body>
    <div id="hero">
      <div id="output">
        <div id="progressBar"></div>
        <!-- The video player will be added here -->
      </div>
      <!-- Statistics -->
      <div id="status">
        <div>
          <span class="show-leech">Downloading </span>
          <span class="show-seed">Seeding </span>
          <code>
            <!-- Informative link to the torrent file -->
            <a id="torrentLink" href="https://webtorrent.io/torrents/sintel.torrent">sintel.torrent</a>
          </code>
          <span class="show-leech"> from </span>
          <span class="show-seed"> to </span>
          <code id="numPeers">0 peers</code>.
        </div>
        <div>
          <code id="downloaded"></code>
          of <code id="total"></code><span id="remaining"></span><br/>
          &#x2198;<code id="downloadSpeed">0 b/s</code>
          / &#x2197;<code id="uploadSpeed">0 b/s</code>
        </div>
      </div>
    </div>
    <!-- Include the latest version of WebTorrent -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/webtorrent.min.js"></script>

    <!-- Moment is used to show a human-readable remaining time -->
    <script src="http://momentjs.com/downloads/moment.min.js"></script>

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

      var client = new WebTorrent()

      // HTML elements
      var $body = document.body
      var $progressBar = document.querySelector('#progressBar')
      var $numPeers = document.querySelector('#numPeers')
      var $downloaded = document.querySelector('#downloaded')
      var $total = document.querySelector('#total')
      var $remaining = document.querySelector('#remaining')
      var $uploadSpeed = document.querySelector('#uploadSpeed')
      var $downloadSpeed = document.querySelector('#downloadSpeed')

      // Download the torrent
      client.add(torrentId, function (torrent) {

        // Torrents can contain many files. Let's use the .mp4 file
        var file = torrent.files.find(function (file) {
          return file.name.endsWith('.mp4')
        })

        // Stream the file in the browser
        file.appendTo('#output')

        // Trigger statistics refresh
        torrent.on('done', onDone)
        setInterval(onProgress, 500)
        onProgress()

        // Statistics
        function onProgress () {
          // Peers
          $numPeers.innerHTML = torrent.numPeers + (torrent.numPeers === 1 ? ' peer' : ' peers')

          // Progress
          var percent = Math.round(torrent.progress * 100 * 100) / 100
          $progressBar.style.width = percent + '%'
          $downloaded.innerHTML = prettyBytes(torrent.downloaded)
          $total.innerHTML = prettyBytes(torrent.length)

          // Remaining time
          var remaining
          if (torrent.done) {
            remaining = 'Done.'
          } else {
            remaining = moment.duration(torrent.timeRemaining / 1000, 'seconds').humanize()
            remaining = remaining[0].toUpperCase() + remaining.substring(1) + ' remaining.'
          }
          $remaining.innerHTML = remaining

          // Speed rates
          $downloadSpeed.innerHTML = prettyBytes(torrent.downloadSpeed) + '/s'
          $uploadSpeed.innerHTML = prettyBytes(torrent.uploadSpeed) + '/s'
        }
        function onDone () {
          $body.className += ' is-seed'
          onProgress()
        }
      })

      // Human readable bytes util
      function prettyBytes(num) {
        var exponent, unit, neg = num < 0, units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
        if (neg) num = -num
        if (num < 1) return (neg ? '-' : '') + num + ' B'
        exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1)
        num = Number((num / Math.pow(1000, exponent)).toFixed(2))
        unit = units[exponent]
        return (neg ? '-' : '') + num + ' ' + unit
      }
    </script>
  </body>
</html>

 

Share this post


Link to post
Share on other sites

Hola, no he utilizado eso nunca, supongo que harás streaming en un servidor y cogerás la url, si es eso, te adatado el código que dejas, en el archivo t.streaming.tpl edítalo poniendo tu url aquí

torrentId = 'URL'

subes todos los archivos, en extras.css añades esto

#output video{width:100%}#progressBar{height:5px;width:0%;background-color:#35b44f;transition:width .4s ease-in-out}body.is-seed .show-seed{display:inline}body.is-seed .show-leech{display:none}.show-seed{display:none}#status code{font-size:90%;font-weight:700;margin-left:3px;margin-right:3px;border-bottom:1px dashed rgba(255,255,255,.3)}.is-seed #hero{background-color:#154820;transition:.5s .5s background-color ease-in-out}#hero{background-color:#2a3749}#status{color:#000;font-size:17px;padding:5px}a:link,a:visited{color:#30a247;text-decoration:none}

ya lo pones a tu gusto, le puedes añadir chat o lo que quieras, y en head_menu.tpl donde quieras añades esto

<a {if $tsPage == 'streaming'}class="aqui"{/if} href="{$tsConfig.url}/streaming/"><i class="fas fa-video" aria-hidden="true" style="margin-right: 10px;"></i>Streaming</a>

 

f_b439cd29ef08.png

 

https://mega.nz/#!MYpnRAxZ!aAyT56rBAEWrNp2ecz0uwDfDS24gkkb6w3NqcE2Updo

 

 

Share this post


Link to post
Share on other sites

Hola, no he utilizado eso nunca, supongo que harás streaming en un servidor y cogerás la url, si es eso, te adatado el código que dejas, en el archivo t.streaming.tpl edítalo poniendo tu url aquí

torrentId = 'URL'

que bueno Tronlar, la pregunta es como puedo agregarlo desde el post con una iframe algo asi
 

[webtorrent url=”https://webtorrent.io/torrents/sintel.torrent” show_seed_leech_info=”false”] 


lo que haz adaptado tu solo me deja poner una unica URL o puedo mas por que con lo que dices solo podre desde t.streaming.tpl

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Patrocinador



  • ×