aboutsummaryrefslogtreecommitdiffstats
path: root/src/media-timeline.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/media-timeline.js')
-rw-r--r--src/media-timeline.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/media-timeline.js b/src/media-timeline.js
index 8b6045e..a70a46c 100644
--- a/src/media-timeline.js
+++ b/src/media-timeline.js
@@ -20,6 +20,18 @@ export function readMoment(event, depth = 0) {
const tag = event?.tags?.find(t => t[0] === 'media');
return tag && /^\d+$/.test(tag[2] || '') ? mediaMoment(tag[1], Number(tag[2])) : null;
}
+// "didn't intend to tie it to the video timestamp but i guess it did by
+// default" (Adam, 2026-11-14, a zap with a comment on a clip he'd played).
+// A reply, zap or reaction made while a clip has played is ABOUT that
+// moment only when asked: this toggle, off until tapped.
+export function momentToggle(h, moment, on, onToggle, label) {
+ if (!moment) return null;
+ return h('button', {
+ type: 'button', class: 'moment-toggle' + (on ? ' on' : ''), 'aria-pressed': on ? 'true' : 'false',
+ onClick: (e) => { e.stopPropagation(); onToggle(!on); },
+ }, h('span', { 'aria-hidden': 'true' }, on ? '\u2713' : '\u23f1'), ' ', label);
+}
+
export function mediaClock(seconds) {
const s = Math.max(0, Math.floor(seconds || 0));
return Math.floor(s / 60) + ':' + String(s % 60).padStart(2, '0');
@@ -85,7 +97,7 @@ export function markAt(seconds, duration) {
// with closures pointing at a detached player. What was said, reacted or
// zapped at a moment sits on the bar at that moment; replies, reactions and
// zaps made while a clip plays carry its time on their own (see momentOf).
-export function mediaTimeline(player, url, { h, event, moments, glyph, label }) {
+export function mediaTimeline(player, url, { h, event, moments, glyph, label, onMarks = null }) {
const audio = player.tagName === 'AUDIO';
const box = h('div', { class: 'media-timeline', onClick: e => e.stopPropagation(), onPointerdown: e => e.stopPropagation() });
box._skipMorph = true;
@@ -123,6 +135,10 @@ export function mediaTimeline(player, url, { h, event, moments, glyph, label })
}
const items = ev && finite ? moments(ev.id, url) : [];
const next = items.map(x => x.id).join(',') + '@' + (finite ? player.duration : 0);
+ // a video has its own seek bar: this one shows under it only to carry
+ // what was said at a moment (two bars read as a glitch on a phone)
+ box.classList.toggle('has-marks', items.length > 0);
+ if (onMarks) onMarks(items.length > 0);
if (signature !== next) {
signature = next;
marks.replaceChildren(...items.map(x => h('button', { type: 'button', class: 'media-mark', title: mediaClock(x.moment.seconds) + ' ' + x.text,