Fix issue with spacebar pausing in chromium, allow exit fullscreen with f hotkey
This commit is contained in:
@@ -32,8 +32,6 @@ export const set_file = async file => {
|
||||
file.availability === "ip_download_limited_captcha_required"
|
||||
) {
|
||||
viewer_type = "rate_limit"
|
||||
} else if (!premium_download && $stats.limits.transfer_limit_used > $stats.limits.transfer_limit) {
|
||||
viewer_type = "slow_down"
|
||||
} else {
|
||||
viewer_type = file_type(file)
|
||||
}
|
||||
@@ -67,7 +65,7 @@ export const seek = delta => {
|
||||
</div>
|
||||
{:else if viewer_type === "abuse"}
|
||||
<Abuse bind:this={viewer} on:download></Abuse>
|
||||
{:else if viewer_type === "slow_down"}
|
||||
{:else if !premium_download && $stats.limits.transfer_limit_used > $stats.limits.transfer_limit}
|
||||
<SlowDown
|
||||
on:download
|
||||
file_size={current_file.size}
|
||||
|
@@ -83,7 +83,11 @@ const mute = () => {
|
||||
}
|
||||
|
||||
const fullscreen = () => {
|
||||
player.requestFullscreen()
|
||||
if (document.fullscreenElement === null) {
|
||||
player.requestFullscreen()
|
||||
} else {
|
||||
document.exitFullscreen()
|
||||
}
|
||||
}
|
||||
|
||||
const keypress = e => {
|
||||
@@ -104,6 +108,14 @@ const keypress = e => {
|
||||
fullscreen()
|
||||
}
|
||||
}
|
||||
const video_keydown = e => {
|
||||
if (e.key === " ") {
|
||||
// Prevent spacebar from pausing playback in Chromium. This conflicts
|
||||
// with our own global key handler, causing the video to immediately
|
||||
// pause again after unpausing.
|
||||
e.stopPropagation()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keypress={keypress} />
|
||||
@@ -135,6 +147,7 @@ const keypress = e => {
|
||||
on:pause={() => playing = false }
|
||||
on:play={() => playing = true }
|
||||
on:ended={() => dispatch("next", {})}
|
||||
on:keydown={video_keydown}
|
||||
>
|
||||
<source src={file.get_href} type={file.mime_type} />
|
||||
</video>
|
||||
|
@@ -71,8 +71,22 @@ const mute = () => {
|
||||
}
|
||||
|
||||
const fullscreen = () => {
|
||||
player.requestFullscreen()
|
||||
if (document.fullscreenElement === null) {
|
||||
player.requestFullscreen()
|
||||
} else {
|
||||
document.exitFullscreen()
|
||||
}
|
||||
}
|
||||
|
||||
const video_keydown = e => {
|
||||
if (e.key === " ") {
|
||||
// Prevent spacebar from pausing playback in Chromium. This conflicts
|
||||
// with our own global key handler, causing the video to immediately
|
||||
// pause again after unpausing.
|
||||
e.stopPropagation()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
@@ -101,6 +115,7 @@ const fullscreen = () => {
|
||||
on:pause={() => playing = false }
|
||||
on:play={() => playing = true }
|
||||
on:ended={() => dispatch("open_sibling", 1)}
|
||||
on:keydown={video_keydown}
|
||||
>
|
||||
<source src={fs_path_url($nav.base.path)} type={$nav.base.file_type} />
|
||||
</video>
|
||||
|
Reference in New Issue
Block a user