mirror of
https://github.com/imgfloat/server.git
synced 2026-11-05 06:44:08 +00:00
Fix mute pausing videos
This commit is contained in:
1 parent
519ebbaaff
commit
d01780c563
4 files changed
+35
-11
No files matched your search
@@ -961,6 +961,7 @@ function applyMediaSettings(element, asset) {
|
||||
}
|
||||
const nextSpeed = asset.speed ?? 1;
|
||||
const effectiveSpeed = Math.max(nextSpeed, 0.01);
|
||||
const wasMuted = element.muted;
|
||||
if (element.playbackRate !== effectiveSpeed) {
|
||||
element.playbackRate = effectiveSpeed;
|
||||
}
|
||||
@@ -968,7 +969,19 @@ function applyMediaSettings(element, asset) {
|
||||
if (element.muted !== shouldMute) {
|
||||
element.muted = shouldMute;
|
||||
}
|
||||
element.pause();
|
||||
if (nextSpeed === 0) {
|
||||
element.pause();
|
||||
return;
|
||||
}
|
||||
const playPromise = element.play();
|
||||
if (playPromise?.catch) {
|
||||
playPromise.catch(() => {
|
||||
if (!shouldMute && wasMuted) {
|
||||
element.muted = true;
|
||||
element.play().catch(() => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function renderAssetList() {
|
||||
|
||||
@@ -670,6 +670,7 @@ function applyMediaSettings(element, asset) {
|
||||
}
|
||||
const nextSpeed = asset.speed ?? 1;
|
||||
const effectiveSpeed = Math.max(nextSpeed, 0.01);
|
||||
const wasMuted = element.muted;
|
||||
if (element.playbackRate !== effectiveSpeed) {
|
||||
element.playbackRate = effectiveSpeed;
|
||||
}
|
||||
@@ -679,8 +680,16 @@ function applyMediaSettings(element, asset) {
|
||||
}
|
||||
if (nextSpeed === 0) {
|
||||
element.pause();
|
||||
} else if (element.paused) {
|
||||
element.play().catch(() => {});
|
||||
} else {
|
||||
const playPromise = element.play();
|
||||
if (playPromise?.catch) {
|
||||
playPromise.catch(() => {
|
||||
if (!shouldMute && wasMuted) {
|
||||
element.muted = true;
|
||||
element.play().catch(() => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user