forge
Explore
Log in

Don't you dare go Hollow

Volume and speed on the house player, title chip alignment

Browse files at this commit

f00f8a33195b10cf51228a91936002f1412c7126Ahmet Kaan GümüşParent: e114125
  • feat
    • volume and speed on the house player, title chip alignment
Show full message
feat(ui): volume and speed on the house player, title chip alignment

The controls bar both players share (one helper, wired by class) gains a
mute toggle with the house speaker glyph, a level slider wearing the seek
bar's styling, and a speed cycle — 0.5/0.75/1/1.25/1.5/2, the label reads
the current rate. Fullscreen stays video-only. The audio bar widens to
hold the new controls without crowding the seek.

The viewer title was a plain block: the 24px chip (thumb or mime glyph)
hung off the text baseline beside an 18px name. It is a centered flex row
now — the share and move modal titles already were.
crates/in-web/src/files.rsmodified+53 -22
@@ -497,29 +497,10 @@ async fn view_file(cx: &Cx) -> Result {
497 Some(ViewerKind::Image) => <img class="viewer-media" src=(src.clone()) alt=(file.name.clone()) draggable="false">,497 Some(ViewerKind::Image) => <img class="viewer-media" src=(src.clone()) alt=(file.name.clone()) draggable="false">,
498 Some(ViewerKind::Video) => <div class="media-player media-player-video">498 Some(ViewerKind::Video) => <div class="media-player media-player-video">
499 <video class="media-el viewer-video" src=(src.clone()) preload="metadata"></video>499 <video class="media-el viewer-video" src=(src.clone()) preload="metadata"></video>
500- <div class="media-controls">500+ <div class="media-controls">(media_controls(cx, language, file.name.clone(), true).await?)</div>
501- <button type="button" class="media-play" aria-label=(t(language, Key::Play))
502- data-play=(t(language, Key::Play)) data-pause=(t(language, Key::Pause))>
503- <svg class="glyph glyph-play" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 3.5v9l7.5-4.5z"></path></svg>
504- <svg class="glyph glyph-pause" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5.5 3.5v9M10.5 3.5v9"></path></svg>
505- </button>
506- <span class="media-time media-now">"0:00"</span>
507- <input class="media-seek" type="range" min="0" max="1000" value="0" aria-label=(file.name.clone())>
508- <span class="media-time media-dur">"0:00"</span>
509- <button type="button" class="media-full" aria-label=(t(language, Key::Fullscreen))>
510- <svg class="glyph" width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="M6 2H2v4M10 2h4v4M14 10v4h-4M2 10v4h4"></path></svg>
511- </button>
512- </div>
513 </div>,501 </div>,
514 Some(ViewerKind::Audio) => <div class="media-player">502 Some(ViewerKind::Audio) => <div class="media-player">
515- <button type="button" class="media-play" aria-label=(t(language, Key::Play))503+ (media_controls(cx, language, file.name.clone(), false).await?)
516- data-play=(t(language, Key::Play)) data-pause=(t(language, Key::Pause))>
517- <svg class="glyph glyph-play" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 3.5v9l7.5-4.5z"></path></svg>
518- <svg class="glyph glyph-pause" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5.5 3.5v9M10.5 3.5v9"></path></svg>
519- </button>
520- <span class="media-time media-now">"0:00"</span>
521- <input class="media-seek" type="range" min="0" max="1000" value="0" aria-label=(file.name.clone())>
522- <span class="media-time media-dur">"0:00"</span>
523 <audio class="media-el" src=(src.clone()) preload="metadata"></audio>504 <audio class="media-el" src=(src.clone()) preload="metadata"></audio>
524 </div>,505 </div>,
525 Some(ViewerKind::Pdf) => <object class="viewer-media viewer-pdf" data=(src.clone()) type="application/pdf">506 Some(ViewerKind::Pdf) => <object class="viewer-media viewer-pdf" data=(src.clone()) type="application/pdf">
@@ -561,6 +542,35 @@ async fn view_file(cx: &Cx) -> Result {
561 }542 }
562 }543 }
563 544
545+/// The one controls bar both media players draw: play toggle, clock, seek,
546+/// volume (mute + level), a speed cycle, and fullscreen on video. The script
547+/// below wires it by class, so the bar stays markup-only.
548+async fn media_controls(cx: &Cx, language: crate::i18n::Lang, name: String, video: bool) -> Result {
549+ view! {
550+ cx =>
551+ <button type="button" class="media-play" aria-label=(t(language, Key::Play))
552+ data-play=(t(language, Key::Play)) data-pause=(t(language, Key::Pause))>
553+ <svg class="glyph glyph-play" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 3.5v9l7.5-4.5z"></path></svg>
554+ <svg class="glyph glyph-pause" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5.5 3.5v9M10.5 3.5v9"></path></svg>
555+ </button>
556+ <span class="media-time media-now">"0:00"</span>
557+ <input class="media-seek" type="range" min="0" max="1000" value="0" aria-label=(name)>
558+ <span class="media-time media-dur">"0:00"</span>
559+ <button type="button" class="media-vol" aria-label=(t(language, Key::Mute))
560+ data-mute=(t(language, Key::Mute)) data-unmute=(t(language, Key::Unmute))>
561+ <svg class="glyph glyph-vol-on" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 3.5 4 6H2v4h2l3.5 2.5z" fill="currentColor"></path><path d="M10 6a3 3 0 010 4M12 4a6.4 6.4 0 010 8"></path></svg>
562+ <svg class="glyph glyph-vol-off" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 3.5 4 6H2v4h2l3.5 2.5z" fill="currentColor"></path><path d="M10 6l4 4M14 6l-4 4"></path></svg>
563+ </button>
564+ <input class="media-vol-slider" type="range" min="0" max="100" value="100" aria-label=(t(language, Key::Volume))>
565+ <button type="button" class="media-speed" aria-label=(t(language, Key::PlaybackSpeed))>"1×"</button>
566+ if video {
567+ <button type="button" class="media-full" aria-label=(t(language, Key::Fullscreen))>
568+ <svg class="glyph" width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="M6 2H2v4M10 2h4v4M14 10v4h-4M2 10v4h4"></path></svg>
569+ </button>
570+ }
571+ }
572+}
573+
564 /// The house media player: play toggle, clock, seek bar — and a fullscreen574 /// The house media player: play toggle, clock, seek bar — and a fullscreen
565 /// button on video — over a controls-less `<audio>`/`<video>`. Native575 /// button on video — over a controls-less `<audio>`/`<video>`. Native
566 /// controls are the browser's own chrome: they ignore the theme's shape576 /// controls are the browser's own chrome: they ignore the theme's shape
@@ -584,7 +594,9 @@ async fn media_player_script(cx: &Cx) -> Result {
584 var seek = player.querySelector('.media-seek'); \594 var seek = player.querySelector('.media-seek'); \
585 var now = player.querySelector('.media-now'); \595 var now = player.querySelector('.media-now'); \
586 var dur = player.querySelector('.media-dur'); \596 var dur = player.querySelector('.media-dur'); \
587- var full = player.querySelector('.media-full'); \597+ var volBtn = player.querySelector('.media-vol'); \
598+ var volSlider = player.querySelector('.media-vol-slider'); \
599+ var speed = player.querySelector('.media-speed'); \
588 function clock(s) { \600 function clock(s) { \
589 if (!isFinite(s)) { return '0:00'; } \601 if (!isFinite(s)) { return '0:00'; } \
590 var m = Math.floor(s / 60); \602 var m = Math.floor(s / 60); \
@@ -613,6 +625,25 @@ async fn media_player_script(cx: &Cx) -> Result {
613 seek.addEventListener('input', function () { \625 seek.addEventListener('input', function () { \
614 if (media.duration) { media.currentTime = seek.value / 1000 * media.duration; } \626 if (media.duration) { media.currentTime = seek.value / 1000 * media.duration; } \
615 }); \627 }); \
628+ volBtn.addEventListener('click', function () { media.muted = !media.muted; }); \
629+ media.addEventListener('volumechange', function () { \
630+ window.__inOwn(player, ['media-muted'], []); \
631+ player.classList.toggle('media-muted', media.muted || media.volume === 0); \
632+ if (!media.muted) { volSlider.value = media.volume * 100; } \
633+ volBtn.setAttribute('aria-label', volBtn.getAttribute(media.muted ? 'data-unmute' : 'data-mute')); \
634+ }); \
635+ volSlider.addEventListener('input', function () { \
636+ media.muted = false; \
637+ media.volume = volSlider.value / 100; \
638+ }); \
639+ /* The speed button cycles the house ladder; the label is the \
640+ current rate, '1×' at the top of a lap. */ \
641+ var rates = [0.5, 0.75, 1, 1.25, 1.5, 2]; \
642+ speed.addEventListener('click', function () { \
643+ var next = rates[(rates.indexOf(media.playbackRate) + 1) % rates.length]; \
644+ media.playbackRate = next; \
645+ speed.textContent = next + '×'; \
646+ }); \
616 if (full) { \647 if (full) { \
617 full.addEventListener('click', function () { \648 full.addEventListener('click', function () { \
618 if (document.fullscreenElement) { document.exitFullscreen(); } \649 if (document.fullscreenElement) { document.exitFullscreen(); } \
crates/in-web/src/i18n.rsmodified+12 -0
@@ -127,6 +127,10 @@ pub enum Key {
127 Play,127 Play,
128 Pause,128 Pause,
129 Fullscreen,129 Fullscreen,
130+ Mute,
131+ Unmute,
132+ Volume,
133+ PlaybackSpeed,
130 RenameFile,134 RenameFile,
131 DeleteFile,135 DeleteFile,
132 // Share.136 // Share.
@@ -277,6 +281,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
277 FileDetails => "File",281 FileDetails => "File",
278 PreviewUnavailable => "No preview for this kind of file.",282 PreviewUnavailable => "No preview for this kind of file.",
279 Play => "Play",283 Play => "Play",
284+ Mute => "Mute",
285+ Volume => "Volume",
286+ Unmute => "Unmute",
287+ PlaybackSpeed => "Playback speed",
280 Pause => "Pause",288 Pause => "Pause",
281 Fullscreen => "Fullscreen",289 Fullscreen => "Fullscreen",
282 RenameFile => "Rename file",290 RenameFile => "Rename file",
@@ -419,6 +427,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
419 DeleteFile => "Dosyayı sil",427 DeleteFile => "Dosyayı sil",
420 Share => "Paylaş",428 Share => "Paylaş",
421 Play => "Oynat",429 Play => "Oynat",
430+ Mute => "Sessize al",
431+ Unmute => "Sesi aç",
432+ PlaybackSpeed => "Oynatma hızı",
433+ Volume => "Ses",
422 Pause => "Duraklat",434 Pause => "Duraklat",
423 Fullscreen => "Tam ekran",435 Fullscreen => "Tam ekran",
424 ShareLink => "Paylaşım bağlantısı",436 ShareLink => "Paylaşım bağlantısı",
style/main.scssmodified+41 -8
@@ -1302,8 +1302,8 @@ img.avatar {
1302 .media-player {1302 .media-player {
1303 display: flex;1303 display: flex;
1304 align-items: center;1304 align-items: center;
1305- gap: 12px;1305+ gap: 10px;
1306- width: min(480px, 80vw);1306+ width: min(560px, 80vw);
1307 padding: 12px 16px;1307 padding: 12px 16px;
1308 background: var(--surface);1308 background: var(--surface);
1309 border: 1px solid var(--border);1309 border: 1px solid var(--border);
@@ -1373,16 +1373,25 @@ img.avatar {
1373 min-width: 34px;1373 min-width: 34px;
1374 text-align: center;1374 text-align: center;
1375 }1375 }
1376-1376+.media-seek, .media-vol-slider {
1377-.media-seek {
1378- flex: 1;
1379 appearance: none;1377 appearance: none;
1380 height: 4px;1378 height: 4px;
1381 margin: 0;1379 margin: 0;
1382 background: var(--border);1380 background: var(--border);
1383 border-radius: 2px;1381 border-radius: 2px;
1384 cursor: pointer;1382 cursor: pointer;
1383+}
1385 1384
1385+.media-seek {
1386+ flex: 1;
1387+}
1388+
1389+.media-vol-slider {
1390+ width: 64px;
1391+ flex: none;
1392+}
1393+
1394+.media-seek, .media-vol-slider {
1386 &::-webkit-slider-thumb {1395 &::-webkit-slider-thumb {
1387 appearance: none;1396 appearance: none;
1388 width: 12px;1397 width: 12px;
@@ -1413,7 +1422,7 @@ img.avatar {
1413 }1422 }
1414 }1423 }
1415 1424
1416-.media-full {1425+.media-full, .media-vol {
1417 display: grid;1426 display: grid;
1418 place-items: center;1427 place-items: center;
1419 width: 28px;1428 width: 28px;
@@ -1429,6 +1438,29 @@ img.avatar {
1429 &:hover { background: var(--row-hover); color: var(--ink); }1438 &:hover { background: var(--row-hover); color: var(--ink); }
1430 }1439 }
1431 1440
1441+.media-vol .glyph-vol-off { display: none; }
1442+.media-muted .media-vol {
1443+ .glyph-vol-on { display: none; }
1444+ .glyph-vol-off { display: block; }
1445+}
1446+
1447+// The speed cycle reads as a value, not an icon: mono, quiet, button-sized.
1448+.media-speed {
1449+ flex: none;
1450+ min-width: 38px;
1451+ height: 28px;
1452+ padding: 0 4px;
1453+ border: none;
1454+ border-radius: var(--radius);
1455+ background: none;
1456+ font-family: var(--font-mono);
1457+ font-size: 12px;
1458+ color: var(--muted);
1459+ cursor: pointer;
1460+
1461+ &:hover { background: var(--row-hover); color: var(--ink); }
1462+}
1463+
1432 // Fullscreen re-frames the same player: the picture takes the screen and the1464 // Fullscreen re-frames the same player: the picture takes the screen and the
1433 // bar settles at its bottom.1465 // bar settles at its bottom.
1434 .media-player-video:fullscreen {1466 .media-player-video:fullscreen {
@@ -4648,13 +4680,14 @@ input[type="radio"] {
4648 margin-bottom: 12px;4680 margin-bottom: 12px;
4649 }4681 }
4650 4682
4651-.viewer-title { overflow-wrap: anywhere; }4683+// The title's chip (a thumb or the mime glyph) centers against the name —
4684+// as a plain block the 24px box hangs off the text's baseline.
4685+.viewer-title { overflow-wrap: anywhere; display: flex; align-items: center; gap: 10px; }
4652 4686
4653 .viewer-stage {4687 .viewer-stage {
4654 display: flex;4688 display: flex;
4655 flex-direction: column;4689 flex-direction: column;
4656 justify-content: center;4690 justify-content: center;
4657- width: 100%;
4658 max-width: min(100%, 960px);4691 max-width: min(100%, 960px);
4659 margin: 16px auto;4692 margin: 16px auto;
4660 padding: 20px 24px 24px;4693 padding: 20px 24px 24px;