diff --git a/app/js/playerHandler.js b/app/js/playerHandler.js index e329742..6ae7718 100644 --- a/app/js/playerHandler.js +++ b/app/js/playerHandler.js @@ -8,7 +8,7 @@ for (let item of controls) { } // event listeners -volume.addEventListener("input", ()=> updateVolume()); +volume.addEventListener("input", () => updateVolume()); progress.addEventListener("input", dragBar); progress.addEventListener("mouseup", dragBarEnd); progress.addEventListener("touchend", dragBarEnd); @@ -130,13 +130,11 @@ function createThumbnail(vid) { } } -function finishThumbnails(file) { +function finishThumbnails(url) { if (settings.player5 && settings.player8) { let thumbVid = document.createElement("video") - playerData.thumbnails = [] - file.getBlobURL((err, url) => { - thumbVid.src = url - }) + thumbVid.src = url + thumbVid.addEventListener('loadeddata', () => { loadTime(); }) @@ -157,11 +155,9 @@ function finishThumbnails(file) { } //file download -function downloadFile(file) { - file.getBlobURL((err, url) => { - dl.href = url - dl.download = file.name - }) +function downloadFile(url, name) { + dl.href = url + dl.download = name } // bufering spinner @@ -396,10 +392,10 @@ document.onkeydown = (a) => { seek(parseInt(settings.player3)); break; case "ArrowUp": - updateVolume(parseInt(volume.value)+5) + updateVolume(parseInt(volume.value) + 5) break; case "ArrowDown": - updateVolume(parseInt(volume.value)-5) + updateVolume(parseInt(volume.value) - 5) break; } } diff --git a/app/js/torrentHandler.js b/app/js/torrentHandler.js index 8c99cfe..df971da 100644 --- a/app/js/torrentHandler.js +++ b/app/js/torrentHandler.js @@ -86,16 +86,18 @@ async function addTorrent(magnet) { alertType: "alert-success", fillType: "" }); - finishThumbnails(videoFile); - downloadFile(videoFile) - postDownload(videoFile) + videoFile.getBlobURL((err, url) => { + finishThumbnails(url); + downloadFile(url, videoFile.name) + postDownload(url, videoFile) + }) }) video.src = `${scope}webtorrent/${torrent.infoHash}/${encodeURI(videoFile.path)}` video.load() }) } -function postDownload(file) { +function postDownload(url, file) { if (settings.player8) { let parser = new SubtitleParser(), subtitles = [] @@ -113,16 +115,13 @@ function postDownload(file) { } }) parser.on('finish', () => { - console.log("finish") playerData.subtitles = subtitles renderSubs.call(null, 3) - file.getBlobURL((err, url) => { - let time = video.currentTime, - playState = !video.paused - video.src = url - video.currentTime = time - playState ? video.play() : "" - }) + let time = video.currentTime, + playState = !video.paused + video.src = url + video.currentTime = time + playState ? video.play() : "" }); file.createReadStream().pipe(parser) }