mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-14 22:48:44 +01:00
add limit speed cpu
This commit is contained in:
parent
bbc27dc37f
commit
5b9da606fd
1 changed files with 5 additions and 12 deletions
17
css/app.js
17
css/app.js
|
@ -335,23 +335,15 @@ speedOption.addEventListener("click", function() {
|
||||||
var currentSpeed = video.playbackRate;
|
var currentSpeed = video.playbackRate;
|
||||||
var newSpeed = getNextSpeed(currentSpeed);
|
var newSpeed = getNextSpeed(currentSpeed);
|
||||||
|
|
||||||
if (navigator.hardwareConcurrency < 3) {
|
|
||||||
var userChoice = confirm(
|
|
||||||
"Your system has less than 3 CPU cores ;_; Increasing the video speed will CPU usage and affect performance - Do u want to continue?"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!userChoice) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
video.playbackRate = newSpeed;
|
video.playbackRate = newSpeed;
|
||||||
document.getElementById("aud").playbackRate = newSpeed;
|
document.getElementById("aud").playbackRate = newSpeed;
|
||||||
speedOption.innerHTML = "<i class='fa-light fa-gauge'></i> Speed: " + newSpeed.toFixed(2) + "x";
|
speedOption.innerHTML = "<i class='fa-light fa-gauge'></i> Speed: " + newSpeed.toFixed(2) + "x";
|
||||||
});
|
});
|
||||||
|
|
||||||
function getNextSpeed(currentSpeed) {
|
function getNextSpeed(currentSpeed) {
|
||||||
if (currentSpeed === 2) {
|
var maxSpeed = (navigator.hardwareConcurrency < 3) ? 1 : 2; // Limit max speed based on CPU cores - for optimization
|
||||||
|
|
||||||
|
if (currentSpeed === maxSpeed) {
|
||||||
return 0.25;
|
return 0.25;
|
||||||
} else if (currentSpeed === 0.25) {
|
} else if (currentSpeed === 0.25) {
|
||||||
return 0.5;
|
return 0.5;
|
||||||
|
@ -360,9 +352,10 @@ function getNextSpeed(currentSpeed) {
|
||||||
} else if (currentSpeed === 0.75) {
|
} else if (currentSpeed === 0.75) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 2;
|
return maxSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const GoogleTranslateEndpoint = "https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&rt=c"
|
const GoogleTranslateEndpoint = "https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&rt=c"
|
||||||
// @license-end
|
// @license-end
|
Loading…
Reference in a new issue