fix: QuickTime-style floating controls pill, speed selector, rate sync
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -127,11 +127,12 @@
|
|||||||
onOpenCaptionSettings();
|
onOpenCaptionSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync PiP/fullscreen state periodically
|
// Sync PiP/fullscreen/rate state periodically
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
pipActive = isPiPActive();
|
pipActive = isPiPActive();
|
||||||
fullscreenActive = isFullscreenActive();
|
fullscreenActive = isFullscreenActive();
|
||||||
|
currentRate = getPlaybackRate();
|
||||||
}, 500);
|
}, 500);
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
});
|
});
|
||||||
@@ -149,56 +150,10 @@
|
|||||||
aria-label="Player controls"
|
aria-label="Player controls"
|
||||||
>
|
>
|
||||||
<div class="player-controls-panel">
|
<div class="player-controls-panel">
|
||||||
<!-- Seek bar -->
|
<!-- Controls row (top) -->
|
||||||
<div
|
|
||||||
class="seek-bar"
|
|
||||||
bind:this={seekBarEl}
|
|
||||||
onmousedown={handleSeekBarMouseDown}
|
|
||||||
onmousemove={handleSeekBarMouseMove}
|
|
||||||
onmouseup={handleSeekBarMouseUp}
|
|
||||||
onmouseleave={handleSeekBarMouseLeave}
|
|
||||||
role="slider"
|
|
||||||
tabindex="0"
|
|
||||||
aria-label="Seek"
|
|
||||||
aria-valuenow={session.currentTime}
|
|
||||||
aria-valuemin={0}
|
|
||||||
aria-valuemax={session.duration}
|
|
||||||
>
|
|
||||||
<div class="seek-track">
|
|
||||||
<div class="seek-fill" style="width: {progress * 100}%"></div>
|
|
||||||
<div class="seek-thumb" style="left: {progress * 100}%"></div>
|
|
||||||
</div>
|
|
||||||
{#if hoverTime !== null}
|
|
||||||
<div class="seek-tooltip" style="left: {hoverX}px">
|
|
||||||
{formatTime(hoverTime)}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Controls row -->
|
|
||||||
<div class="controls-row">
|
<div class="controls-row">
|
||||||
<!-- Left group: playback -->
|
<!-- Left group: volume -->
|
||||||
<div class="controls-group left">
|
<div class="controls-group left">
|
||||||
<button
|
|
||||||
class="ctrl-btn"
|
|
||||||
onclick={() => seekBy(-10)}
|
|
||||||
title="Skip back 10s"
|
|
||||||
type="button"
|
|
||||||
>⏪</button>
|
|
||||||
<button
|
|
||||||
class="ctrl-btn play-btn"
|
|
||||||
onclick={togglePlayPause}
|
|
||||||
title={session.isPlaying ? 'Pause' : 'Play'}
|
|
||||||
type="button"
|
|
||||||
>{session.isPlaying ? '❚❚' : '▶'}</button>
|
|
||||||
<button
|
|
||||||
class="ctrl-btn"
|
|
||||||
onclick={() => seekBy(10)}
|
|
||||||
title="Skip forward 10s"
|
|
||||||
type="button"
|
|
||||||
>⏩</button>
|
|
||||||
|
|
||||||
<!-- Volume -->
|
|
||||||
<button
|
<button
|
||||||
class="ctrl-btn vol-btn"
|
class="ctrl-btn vol-btn"
|
||||||
onclick={handleToggleMute}
|
onclick={handleToggleMute}
|
||||||
@@ -218,13 +173,26 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Center group: time -->
|
<!-- Center group: playback -->
|
||||||
<div class="controls-group center">
|
<div class="controls-group center">
|
||||||
<span class="time-display">
|
<button
|
||||||
{formatTime(session.currentTime)}
|
class="ctrl-btn"
|
||||||
<span class="time-sep">/</span>
|
onclick={() => seekBy(-10)}
|
||||||
{formatTime(session.duration)}
|
title="Skip back 10s"
|
||||||
</span>
|
type="button"
|
||||||
|
>⏪</button>
|
||||||
|
<button
|
||||||
|
class="ctrl-btn play-btn"
|
||||||
|
onclick={togglePlayPause}
|
||||||
|
title={session.isPlaying ? 'Pause' : 'Play'}
|
||||||
|
type="button"
|
||||||
|
>{session.isPlaying ? '❚❚' : '▶'}</button>
|
||||||
|
<button
|
||||||
|
class="ctrl-btn"
|
||||||
|
onclick={() => seekBy(10)}
|
||||||
|
title="Skip forward 10s"
|
||||||
|
type="button"
|
||||||
|
>⏩</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right group: settings -->
|
<!-- Right group: settings -->
|
||||||
@@ -232,7 +200,7 @@
|
|||||||
<div class="speed-wrapper">
|
<div class="speed-wrapper">
|
||||||
<button
|
<button
|
||||||
class="ctrl-btn"
|
class="ctrl-btn"
|
||||||
onclick={() => { showSpeedSelector = !showSpeedSelector; }}
|
onclick={(e) => { e.stopPropagation(); showSpeedSelector = !showSpeedSelector; }}
|
||||||
title="Playback speed"
|
title="Playback speed"
|
||||||
type="button"
|
type="button"
|
||||||
>{currentRate}×</button>
|
>{currentRate}×</button>
|
||||||
@@ -273,15 +241,47 @@
|
|||||||
>{fullscreenActive ? '⤓' : '⛶'}</button>
|
>{fullscreenActive ? '⤓' : '⛶'}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Seek bar (middle) -->
|
||||||
|
<div
|
||||||
|
class="seek-bar"
|
||||||
|
bind:this={seekBarEl}
|
||||||
|
onmousedown={handleSeekBarMouseDown}
|
||||||
|
onmousemove={handleSeekBarMouseMove}
|
||||||
|
onmouseup={handleSeekBarMouseUp}
|
||||||
|
onmouseleave={handleSeekBarMouseLeave}
|
||||||
|
role="slider"
|
||||||
|
tabindex="0"
|
||||||
|
aria-label="Seek"
|
||||||
|
aria-valuenow={session.currentTime}
|
||||||
|
aria-valuemin={0}
|
||||||
|
aria-valuemax={session.duration}
|
||||||
|
>
|
||||||
|
<div class="seek-track">
|
||||||
|
<div class="seek-fill" style="width: {progress * 100}%"></div>
|
||||||
|
<div class="seek-thumb" style="left: {progress * 100}%"></div>
|
||||||
|
</div>
|
||||||
|
{#if hoverTime !== null}
|
||||||
|
<div class="seek-tooltip" style="left: {hoverX}px">
|
||||||
|
{formatTime(hoverTime)}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Timestamps (bottom) -->
|
||||||
|
<div class="timestamps-row">
|
||||||
|
<span class="time-display">{formatTime(session.currentTime)}</span>
|
||||||
|
<span class="time-display">{formatTime(session.duration)}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.player-controls-overlay {
|
.player-controls-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 24px;
|
||||||
left: 0;
|
left: 15%;
|
||||||
right: 0;
|
right: 15%;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.2s ease 0.1s;
|
transition: opacity 0.2s ease 0.1s;
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
background: rgba(0, 0, 0, 0.75);
|
background: rgba(0, 0, 0, 0.75);
|
||||||
backdrop-filter: blur(8px);
|
backdrop-filter: blur(8px);
|
||||||
border-radius: 12px 12px 0 0;
|
border-radius: 12px;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -439,9 +439,10 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.time-sep {
|
.timestamps-row {
|
||||||
color: var(--text-muted, #6c7086);
|
display: flex;
|
||||||
margin: 0 3px;
|
justify-content: space-between;
|
||||||
|
padding: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Speed wrapper --- */
|
/* --- Speed wrapper --- */
|
||||||
|
|||||||
Reference in New Issue
Block a user