move webtorrent back into main window

We keep webtorrent running when the window is “closed” by hiding the
window instead.
This commit is contained in:
Feross Aboukhadijeh
2016-03-01 20:48:22 -08:00
parent bbe982d645
commit 1bfecb80a2
14 changed files with 344 additions and 393 deletions

View File

@@ -0,0 +1,26 @@
module.exports = torrentPoster
var captureVideoFrame = require('./capture-video-frame')
function torrentPoster (torrent, cb) {
if (torrent.ready) onReady()
else torrent.once('ready', onReady)
function onReady () {
// use largest file
var file = torrent.files.reduce(function (a, b) {
return a.length > b.length ? a : b
})
var video = document.createElement('video')
file.renderTo(video)
video.currentTime = 10
video.addEventListener('seeked', onSeeked)
function onSeeked (e) {
video.removeEventListener('seeked', onSeeked)
var buf = captureVideoFrame(video)
cb(null, buf)
}
}
}