mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-19 13:12:08 +00:00
optimization: only create a single blob [had 3...]
This commit is contained in:
parent
a8cbabb6d2
commit
5d644589ad
2 changed files with 20 additions and 25 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue