Files
xenia-pos-local/packages/signage/src/SlideView.jsx
T
bonaminandClaude Opus 5.5 b5361e10ca feat(media): video versions: still frame + a version every screen plays (platform-v2 5.4e)
- services/video.py: background worker (one video at a time, low priority) makes a still
  frame (thumb/card/full WebP) and, when needed, play.mp4 (H.264+AAC, <=1920 px, HDR
  tone-mapped, faststart); the original is kept. Media.processing/progress (migration 0031,
  existing videos queued). ffmpeg from the pinned imageio-ffmpeg wheel; none = as uploaded.
- MOV (video/quicktime) accepted; /api/media/file/<sha>/play served with ranges.
- Signage plays the version (poster = still frame) and tells the screens playing it when ready.
- Manager library: still frames in the grid, preparing progress, status in the details.
- Tests: test_video.py (8), backend 541 passed; e2e media/signage/stack new checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:22 +02:00

45 lines
2.1 KiB
React

// One slide as a TV shows it (plan step 5.6a): picture, video, text or menu board. Used by the
// player (terminal) and the manager's previews. Needs a parent with `container-type: size`.
// media(id) → { src, url, kind, width, height } | null (src: the address or the TV's kept copy)
import { useEffect, useRef } from 'react'
import { MenuSlide, TextSlide } from './Slides.jsx'
export function SlideView({ slide, media, venue, now, pages, page, onEnded, playing = true }) {
return (
<>
{slide.kind === 'image' && <ImageSlide content={slide.content || {}} media={media} />}
{slide.kind === 'video' && <VideoSlide slide={slide} media={media} onEnded={onEnded} playing={playing} />}
{slide.kind === 'text' && <TextSlide content={slide.content || {}} media={media} venue={venue} now={now} />}
{slide.kind === 'menu' && <MenuSlide slide={slide} media={media} venue={venue} now={now} pages={pages || []} page={page || 0} />}
</>
)
}
function ImageSlide({ content, media }) {
const m = content.media_id ? media(content.media_id) : null
return (
<div className="absolute inset-0" style={{ background: content.background_colour || '#000' }}>
{m && <img src={m.src} alt="" className="w-full h-full" style={{ objectFit: content.fit || 'cover' }} data-testid="signage-image" />}
</div>
)
}
function VideoSlide({ slide, media, onEnded, playing }) {
const c = slide.content || {}
const m = c.media_id ? media(c.media_id) : null
const ref = useRef(null)
useEffect(() => {
const v = ref.current
if (!v) return
if (playing) v.play?.().catch(() => {})
else v.pause?.()
}, [m?.src, playing])
return (
<div className="absolute inset-0" style={{ background: c.background_colour || '#000' }}>
{m && <video ref={ref} src={m.src} poster={m.poster} autoPlay={playing} muted={c.muted !== false || !playing} playsInline loop={!slide.video_to_end}
onEnded={slide.video_to_end ? onEnded : undefined} onError={slide.video_to_end ? onEnded : undefined}
className="w-full h-full" style={{ objectFit: c.fit || 'cover' }} data-testid="signage-video" />}
</div>
)
}