UI progress

This commit is contained in:
Feross Aboukhadijeh
2016-03-01 23:38:38 -08:00
parent 6b74c8eb68
commit 1350e3c5b5
3 changed files with 90 additions and 13 deletions

View File

@@ -77,7 +77,6 @@ function handler (action, ...args) {
closePlayer()
}
}
addTorrent()
function onFiles (files) {
// .torrent file = start downloading the torrent
@@ -149,19 +148,23 @@ function torrentReady (torrent) {
torrentPoster(torrent, function (err, buf) {
if (err) return onError(err)
torrent.posterURL = URL.createObjectURL(new Blob([ buf ], { type: 'image/png' }))
console.log(torrent.posterURL)
update()
})
update()
}
function openPlayer (torrent) {
// use largest file
var index = torrent.files.indexOf(torrent.files.reduce(function (a, b) {
return a.length > b.length ? a : b
}))
var server = torrent.createServer()
server.listen(0, function () {
var port = server.address().port
state.player = {
server: server,
url: 'http://localhost:' + port + '/0'
url: 'http://localhost:' + port + '/' + index
}
update()
})