]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix player on embed
authorBigard Florian <florian.bigard@gmail.com>
Wed, 19 Jul 2017 12:07:52 +0000 (14:07 +0200)
committerGitHub <noreply@github.com>
Wed, 19 Jul 2017 12:07:52 +0000 (14:07 +0200)
client/src/standalone/videos/embed.html

index 365dc3fa23b9337cfc41da27c827d96678d07a8d..d4bb74263a576e49d8d8c432c61a1098d6436556 100644 (file)
@@ -71,7 +71,7 @@
     xhttp.send()
   }
 
-  function loadVideoTorrent (magnetUri) {
+  function loadVideoTorrent (magnetUri, player) {
     console.log('Loading video ' + videoId)
     var client = new window.WebTorrent()
 
     client.add(magnetUri, function (torrent) {
       var file = torrent.files[0]
 
-      file.renderTo('video', { autoplay: true })
+      file.renderTo('video', function (err) {
+        if (err) {
+          console.error(err)
+          return
+        }
+
+        // Hack to "simulate" src link in video.js >= 6
+        // If no, we can't play the video after pausing it
+        // https://github.com/videojs/video.js/blob/master/src/js/player.js#L1633
+        player.src = function () { return true }
+
+        player.play()
+      })
     })
   }
 
       })
 
       document.querySelector('.vjs-big-play-button').addEventListener('click', function () {
-        loadVideoTorrent(magnetUri)
-
-        player.play()
+        loadVideoTorrent(magnetUri, player)
       }, false)
     })
   })
 
   </script>
   </body>
-</html>
+</html