|
|
|
@ -99,9 +99,10 @@ export function StudentApp() {
|
|
|
|
const tabs: [string, string, string][] = [['', 'home', t('nav.home')], ['courses', 'grid', t('nav.courses')], ['my', 'book', t('nav.myCourses')], ['help', 'help', t('nav.help')], ['profile', 'user', t('nav.profile')]];
|
|
|
|
const tabs: [string, string, string][] = [['', 'home', t('nav.home')], ['courses', 'grid', t('nav.courses')], ['my', 'book', t('nav.myCourses')], ['help', 'help', t('nav.help')], ['profile', 'user', t('nav.profile')]];
|
|
|
|
const links = tabs.filter(([p]) => p !== 'profile' && (p !== 'my' || signedIn));
|
|
|
|
const links = tabs.filter(([p]) => p !== 'profile' && (p !== 'my' || signedIn));
|
|
|
|
const current = (s: string) => (s === section || (s === 'courses' && (section === 'course')) || (s === 'profile' && (section === 'progress' || section === 'history')) ? 'page' : undefined);
|
|
|
|
const current = (s: string) => (s === section || (s === 'courses' && (section === 'course')) || (s === 'profile' && (section === 'progress' || section === 'history')) ? 'page' : undefined);
|
|
|
|
|
|
|
|
const focus = section === 'learn'; // L1: watching a lesson drops the site links and the marketing footer
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div lang={locale}>
|
|
|
|
<div lang={locale} className={focus ? 's-focus' : undefined}>
|
|
|
|
<header className={`s-top${scrolled ? ' scrolled' : ''}`}>
|
|
|
|
<header className={`s-top${scrolled ? ' scrolled' : ''}`}>
|
|
|
|
<div className="s-top-in">
|
|
|
|
<div className="s-top-in">
|
|
|
|
<button className="brand" onClick={() => go('')} aria-label={settings.brandName}><Logo size={36} /><Logo size={36} mark /></button>
|
|
|
|
<button className="brand" onClick={() => go('')} aria-label={settings.brandName}><Logo size={36} /><Logo size={36} mark /></button>
|
|
|
|
@ -142,7 +143,7 @@ export function StudentApp() {
|
|
|
|
{settings.maintenanceBanner && <div className="banner small" role="status">{settings.maintenanceBanner}</div>}
|
|
|
|
{settings.maintenanceBanner && <div className="banner small" role="status">{settings.maintenanceBanner}</div>}
|
|
|
|
<StudentRoutes />
|
|
|
|
<StudentRoutes />
|
|
|
|
</main>
|
|
|
|
</main>
|
|
|
|
<Footer />
|
|
|
|
{!focus && <Footer />}
|
|
|
|
{signedIn && section !== 'learn' && section !== 'course' && <nav className="s-tabs" aria-label="Main">
|
|
|
|
{signedIn && section !== 'learn' && section !== 'course' && <nav className="s-tabs" aria-label="Main">
|
|
|
|
{tabs.map(([p, icon, label]) => <button key={p} data-tour={p} aria-current={current(p)} onClick={() => go(p ? '/' + p : '')}><Icon name={icon} size={22} />{label}</button>)}
|
|
|
|
{tabs.map(([p, icon, label]) => <button key={p} data-tour={p} aria-current={current(p)} onClick={() => go(p ? '/' + p : '')}><Icon name={icon} size={22} />{label}</button>)}
|
|
|
|
</nav>}
|
|
|
|
</nav>}
|
|
|
|
@ -847,30 +848,33 @@ function AssessmentPage({ slug, id }: { slug?: string; id?: string }) {
|
|
|
|
function Player({ slug, lessonId }: { slug?: string; lessonId?: string }) {
|
|
|
|
function Player({ slug, lessonId }: { slug?: string; lessonId?: string }) {
|
|
|
|
const t = useTranslations();
|
|
|
|
const t = useTranslations();
|
|
|
|
const { courses, me, locale, nav, catalogLoaded, signedIn, viewer } = useApp();
|
|
|
|
const { courses, me, locale, nav, catalogLoaded, signedIn, viewer } = useApp();
|
|
|
|
|
|
|
|
const sheet = useRef<HTMLDialogElement>(null);
|
|
|
|
|
|
|
|
useEffect(() => { sheet.current?.close(); }, [lessonId]); // picking a lesson in the sheet closes it
|
|
|
|
const c = courses.find((x) => x.slug === slug);
|
|
|
|
const c = courses.find((x) => x.slug === slug);
|
|
|
|
const lessons = c ? publishedLessons(c) : [];
|
|
|
|
const lessons = c ? publishedLessons(c) : [];
|
|
|
|
const lesson = lessons.find((l) => l.id === lessonId);
|
|
|
|
const lesson = lessons.find((l) => l.id === lessonId);
|
|
|
|
if (!catalogLoaded) return <Skeleton h={320} />;
|
|
|
|
if (!catalogLoaded) return <Skeleton h={320} />;
|
|
|
|
if (!c || !lesson || !isStudentVisible(c, me)) return <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button>}>{t('course.notFound')}</Empty>;
|
|
|
|
if (!c || !lesson || !isStudentVisible(c, me)) return <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button>}>{t('course.notFound')}</Empty>;
|
|
|
|
const access = lessonAccess(c, lesson, signedIn ? me : null, courses);
|
|
|
|
const access = lessonAccess(c, lesson, signedIn ? me : null, courses);
|
|
|
|
const p = courseProgress(c, me);
|
|
|
|
|
|
|
|
const idx = lessons.indexOf(lesson);
|
|
|
|
const idx = lessons.indexOf(lesson);
|
|
|
|
const next = lessons[idx + 1];
|
|
|
|
const next = lessons[idx + 1];
|
|
|
|
const notes = tr(lesson.translations, locale)?.description;
|
|
|
|
const notes = tr(lesson.translations, locale)?.description;
|
|
|
|
const chapter = c.chapters.find((ch) => ch.lessons.some((l) => l.id === lesson.id));
|
|
|
|
const chapter = c.chapters.find((ch) => ch.lessons.some((l) => l.id === lesson.id));
|
|
|
|
|
|
|
|
// L2: the video comes first; where you are (course, chapter, lesson) sits right under it
|
|
|
|
|
|
|
|
const head = (
|
|
|
|
|
|
|
|
<div className="p-head">
|
|
|
|
|
|
|
|
<p className="p-crumb">
|
|
|
|
|
|
|
|
<button onClick={() => nav(`/${locale}/course/${c.slug}`)} aria-label={`${t('player.back')}: ${ct(c, locale).title}`}><Icon name="back" size={14} />{ct(c, locale).title}</button>
|
|
|
|
|
|
|
|
{chapter && <span>{tr(chapter.translations, locale)?.title}</span>}
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<h1>{idx + 1}. {lessonTitle(lesson, locale)}</h1>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="stack">
|
|
|
|
<div className="stack">
|
|
|
|
<div className="row-between">
|
|
|
|
|
|
|
|
<button className="btn btn-quiet" onClick={() => nav(`/${locale}/course/${c.slug}`)}><Icon name="back" size={16} />{t('player.back')}</button>
|
|
|
|
|
|
|
|
<span className="small muted">{ct(c, locale).title}</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="p-wrap">
|
|
|
|
<div className="p-wrap">
|
|
|
|
<div className="stack">
|
|
|
|
<div className="stack p-main">
|
|
|
|
<div className="stack-sm">
|
|
|
|
{access.ok ? <VideoPanel key={lesson.id} c={c} lesson={lesson} next={next} head={head} /> : <>
|
|
|
|
<span className="small muted">{tr(chapter?.translations, locale)?.title}</span>
|
|
|
|
|
|
|
|
<h1 style={{ fontSize: 'var(--fs-xl)' }}>{idx + 1}. {lessonTitle(lesson, locale)}</h1>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{access.ok ? <VideoPanel key={lesson.id} c={c} lesson={lesson} next={next} /> : (
|
|
|
|
|
|
|
|
<div className="screen"><div className="sim">
|
|
|
|
<div className="screen"><div className="sim">
|
|
|
|
<Icon name="lock" size={36} />
|
|
|
|
<Icon name="lock" size={36} />
|
|
|
|
<p>{t(`player.${access.reason}`)}</p>
|
|
|
|
<p>{t(`player.${access.reason}`)}</p>
|
|
|
|
@ -879,44 +883,63 @@ function Player({ slug, lessonId }: { slug?: string; lessonId?: string }) {
|
|
|
|
{access.reason === 'PREREQUISITE_REQUIRED' && <button className="btn btn-accent" onClick={() => { const pre = courses.find((x) => x.id === c.prerequisiteCourseId); if (pre) nav(`/${locale}/course/${pre.slug}`); }}>{t('course.prereqLink', { title: ct(courses.find((x) => x.id === c.prerequisiteCourseId) ?? c, locale).title })}</button>}
|
|
|
|
{access.reason === 'PREREQUISITE_REQUIRED' && <button className="btn btn-accent" onClick={() => { const pre = courses.find((x) => x.id === c.prerequisiteCourseId); if (pre) nav(`/${locale}/course/${pre.slug}`); }}>{t('course.prereqLink', { title: ct(courses.find((x) => x.id === c.prerequisiteCourseId) ?? c, locale).title })}</button>}
|
|
|
|
{access.reason === 'ACCOUNT_DEACTIVATED' && <button className="btn btn-accent" onClick={() => nav(`/${locale}/help`)}>{t('nav.help')}</button>}
|
|
|
|
{access.reason === 'ACCOUNT_DEACTIVATED' && <button className="btn btn-accent" onClick={() => nav(`/${locale}/help`)}>{t('nav.help')}</button>}
|
|
|
|
</div></div>
|
|
|
|
</div></div>
|
|
|
|
)}
|
|
|
|
{head}
|
|
|
|
<div className="card stack-sm">
|
|
|
|
</>}
|
|
|
|
|
|
|
|
{/* L5: only real lesson notes; no card standing in with the course blurb */}
|
|
|
|
|
|
|
|
{notes && <div className="card stack-sm">
|
|
|
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('player.notes')}</h2>
|
|
|
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('player.notes')}</h2>
|
|
|
|
<p style={{ whiteSpace: 'pre-line', color: 'var(--ink-2)' }}>{notes || ct(c, locale).subtitle || ct(c, locale).description}</p>
|
|
|
|
<p style={{ whiteSpace: 'pre-line', color: 'var(--ink-2)' }}>{notes}</p>
|
|
|
|
</div>
|
|
|
|
</div>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<aside className="card p-side p-side-order" aria-label={t('player.contents')}>
|
|
|
|
<aside className="card p-side p-side-order" aria-label={t('player.contents')}><CourseContents c={c} lesson={lesson} /></aside>
|
|
|
|
<div className="ps-head">
|
|
|
|
|
|
|
|
{owns(me, c.id) && <Ring pct={p.pct} size={52} />}
|
|
|
|
|
|
|
|
<div className="ps-head-txt"><span className="ps-kicker">{t('course.content')}</span><strong>{ct(c, locale).title}</strong>
|
|
|
|
|
|
|
|
{owns(me, c.id) && <span className="small muted num">{t('player.progress', { done: p.done, total: p.total })}</span>}</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{[...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder).map((ch, ci) => {
|
|
|
|
|
|
|
|
const ls = [...ch.lessons].sort((a, b) => a.sortOrder - b.sortOrder).filter((l) => l.isPublished);
|
|
|
|
|
|
|
|
if (!ls.length) return null;
|
|
|
|
|
|
|
|
const doneN = ls.filter((l) => isCompleted(me, l.id)).length;
|
|
|
|
|
|
|
|
return <details key={ch.id} className={`ps-ch${doneN === ls.length ? ' is-done' : ''}`} open={ls.some((l) => l.id === lesson.id) || undefined}>
|
|
|
|
|
|
|
|
<summary>
|
|
|
|
|
|
|
|
<span className="ps-ch-n num">{doneN === ls.length ? <Icon name="check" size={14} /> : String(ci + 1).padStart(2, '0')}</span>
|
|
|
|
|
|
|
|
<span className="ps-ch-txt"><strong>{tr(ch.translations, locale)?.title}</strong><span className="small muted num">{doneN}/{ls.length} · {clock(ls.reduce((a, l) => a + l.durationSec, 0))}</span></span>
|
|
|
|
|
|
|
|
<Icon name="down" size={16} />
|
|
|
|
|
|
|
|
</summary>
|
|
|
|
|
|
|
|
<div className="ps-ch-list">{ls.map((l) => <LessonRow key={l.id} c={c} l={l} current={l.id === lesson.id} />)}</div>
|
|
|
|
|
|
|
|
</details>;
|
|
|
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
</aside>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{viewer && !viewer.id && <p className="small muted">{t('auth.noIdentity')}</p>}
|
|
|
|
{viewer && !viewer.id && <p className="small muted">{t('auth.noIdentity')}</p>}
|
|
|
|
<nav className="l-bar" aria-label={t('player.contents')}>
|
|
|
|
<nav className="l-bar" aria-label={t('player.contents')}>
|
|
|
|
<button disabled={idx === 0} onClick={() => nav(`/${locale}/learn/${c.slug}/${lessons[idx - 1].id}`)}><Icon name="back" size={18} />{t('player.prev')}</button>
|
|
|
|
<button disabled={idx === 0} onClick={() => nav(`/${locale}/learn/${c.slug}/${lessons[idx - 1].id}`)}><Icon name="back" size={18} />{t('player.prev')}</button>
|
|
|
|
<button onClick={() => document.querySelector('.p-side')?.scrollIntoView({ behavior: 'smooth' })}><Icon name="list" size={18} /><span className="num">{idx + 1} / {lessons.length}</span></button>
|
|
|
|
<button aria-haspopup="dialog" onClick={() => sheet.current?.showModal()}><Icon name="list" size={18} /><span className="num">{idx + 1} / {lessons.length}</span></button>
|
|
|
|
<button className="l-next" disabled={!next} onClick={() => nav(`/${locale}/learn/${c.slug}/${next.id}`)}>{t('player.next')}<Icon name="chevron" size={18} /></button>
|
|
|
|
<button className="l-next" disabled={!next} onClick={() => nav(`/${locale}/learn/${c.slug}/${next.id}`)}>{t('player.nextShort')}<Icon name="chevron" size={18} /></button>
|
|
|
|
</nav>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
{/* L6: on phones and tablets the lesson list slides up over the video instead of scrolling the page away from it */}
|
|
|
|
|
|
|
|
<dialog ref={sheet} className="lsheet" aria-label={t('player.contents')} onClick={(e) => { if (e.target === sheet.current) sheet.current?.close(); }}>
|
|
|
|
|
|
|
|
<div className="lsheet-in">
|
|
|
|
|
|
|
|
<div className="lsheet-top"><span className="lsheet-grip" aria-hidden /><button className="icon-btn" aria-label={t('common.close')} onClick={() => sheet.current?.close()}><Icon name="x" size={20} /></button></div>
|
|
|
|
|
|
|
|
<CourseContents c={c} lesson={lesson} />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</dialog>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Lesson }) {
|
|
|
|
// The course's chapters and lessons with progress: the player's sidebar on desktop and its lesson sheet on phones.
|
|
|
|
|
|
|
|
function CourseContents({ c, lesson }: { c: Course; lesson: Lesson }) {
|
|
|
|
|
|
|
|
const t = useTranslations();
|
|
|
|
|
|
|
|
const { me, locale } = useApp();
|
|
|
|
|
|
|
|
const p = courseProgress(c, me);
|
|
|
|
|
|
|
|
return <>
|
|
|
|
|
|
|
|
<div className="ps-head">
|
|
|
|
|
|
|
|
{owns(me, c.id) && <Ring pct={p.pct} size={52} />}
|
|
|
|
|
|
|
|
<div className="ps-head-txt"><span className="ps-kicker">{t('course.content')}</span><strong>{ct(c, locale).title}</strong>
|
|
|
|
|
|
|
|
{owns(me, c.id) && <span className="small muted num">{t('player.progress', { done: p.done, total: p.total })}</span>}</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{[...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder).map((ch, ci) => {
|
|
|
|
|
|
|
|
const ls = [...ch.lessons].sort((a, b) => a.sortOrder - b.sortOrder).filter((l) => l.isPublished);
|
|
|
|
|
|
|
|
if (!ls.length) return null;
|
|
|
|
|
|
|
|
const doneN = ls.filter((l) => isCompleted(me, l.id)).length;
|
|
|
|
|
|
|
|
return <details key={ch.id} className={`ps-ch${doneN === ls.length ? ' is-done' : ''}`} open={ls.some((l) => l.id === lesson.id) || undefined}>
|
|
|
|
|
|
|
|
<summary>
|
|
|
|
|
|
|
|
<span className="ps-ch-n num">{doneN === ls.length ? <Icon name="check" size={14} /> : String(ci + 1).padStart(2, '0')}</span>
|
|
|
|
|
|
|
|
<span className="ps-ch-txt"><strong>{tr(ch.translations, locale)?.title}</strong><span className="small muted num">{doneN}/{ls.length} · {clock(ls.reduce((a, l) => a + l.durationSec, 0))}</span></span>
|
|
|
|
|
|
|
|
<Icon name="down" size={16} />
|
|
|
|
|
|
|
|
</summary>
|
|
|
|
|
|
|
|
<div className="ps-ch-list">{ls.map((l) => <LessonRow key={l.id} c={c} l={l} current={l.id === lesson.id} />)}</div>
|
|
|
|
|
|
|
|
</details>;
|
|
|
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
</>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const AUTO_NEXT_SEC = 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next?: Lesson; head?: ReactNode }) {
|
|
|
|
const t = useTranslations();
|
|
|
|
const t = useTranslations();
|
|
|
|
const { me, locale, nav, ds, write, signedIn, viewer } = useApp();
|
|
|
|
const { me, locale, nav, ds, write, signedIn, viewer } = useApp();
|
|
|
|
const vimeo = !lesson.videoAssetId; // no upload yet: play the Vimeo placeholder instead
|
|
|
|
const vimeo = !lesson.videoAssetId; // no upload yet: play the Vimeo placeholder instead
|
|
|
|
@ -930,6 +953,9 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
const [saver, setSaver] = useState<boolean>(() => !!conn && (conn.saveData || /2g|3g/.test(conn.effectiveType ?? '')));
|
|
|
|
const [saver, setSaver] = useState<boolean>(() => !!conn && (conn.saveData || /2g|3g/.test(conn.effectiveType ?? '')));
|
|
|
|
const [quality, setQuality] = useState('auto');
|
|
|
|
const [quality, setQuality] = useState('auto');
|
|
|
|
const [justDone, setJustDone] = useState(false);
|
|
|
|
const [justDone, setJustDone] = useState(false);
|
|
|
|
|
|
|
|
// L4: when a lesson ends, "up next" appears over the video and plays it after a short count the student can cancel
|
|
|
|
|
|
|
|
const [ended, setEnded] = useState(false);
|
|
|
|
|
|
|
|
const [auto, setAuto] = useState<number | null>(null);
|
|
|
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
|
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
|
|
const frameRef = useRef<HTMLIFrameElement>(null);
|
|
|
|
const frameRef = useRef<HTMLIFrameElement>(null);
|
|
|
|
const screenRef = useRef<HTMLDivElement>(null);
|
|
|
|
const screenRef = useRef<HTMLDivElement>(null);
|
|
|
|
@ -963,8 +989,9 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
let m: any; try { m = typeof e.data === 'string' ? JSON.parse(e.data) : e.data; } catch { return; }
|
|
|
|
let m: any; try { m = typeof e.data === 'string' ? JSON.parse(e.data) : e.data; } catch { return; }
|
|
|
|
if (m.event === 'ready') vlisten();
|
|
|
|
if (m.event === 'ready') vlisten();
|
|
|
|
else if (m.event === 'timeupdate') { setPos(m.data.seconds); if (m.data.duration) setVdur(m.data.duration); }
|
|
|
|
else if (m.event === 'timeupdate') { setPos(m.data.seconds); if (m.data.duration) setVdur(m.data.duration); }
|
|
|
|
else if (m.event === 'play') setPlaying(true);
|
|
|
|
else if (m.event === 'play') { setPlaying(true); setEnded(false); setAuto(null); }
|
|
|
|
else if (m.event === 'pause' || m.event === 'ended') setPlaying(false);
|
|
|
|
else if (m.event === 'pause') setPlaying(false);
|
|
|
|
|
|
|
|
else if (m.event === 'ended') { setPlaying(false); setEnded(true); }
|
|
|
|
else if (m.method === 'getDuration' && m.value) setVdur(m.value);
|
|
|
|
else if (m.method === 'getDuration' && m.value) setVdur(m.value);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
addEventListener('message', on);
|
|
|
|
addEventListener('message', on);
|
|
|
|
@ -979,6 +1006,14 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
}, [heartbeat]);
|
|
|
|
}, [heartbeat]);
|
|
|
|
useEffect(() => { const v = videoRef.current; if (v) v.playbackRate = rate; }, [rate]);
|
|
|
|
useEffect(() => { const v = videoRef.current; if (v) v.playbackRate = rate; }, [rate]);
|
|
|
|
useEffect(() => { if (vimeo && rate !== 1) vcall('setPlaybackRate', rate); }, [rate]);
|
|
|
|
useEffect(() => { if (vimeo && rate !== 1) vcall('setPlaybackRate', rate); }, [rate]);
|
|
|
|
|
|
|
|
const goNext = () => { if (next) nav(`/${locale}/learn/${c.slug}/${next.id}`); };
|
|
|
|
|
|
|
|
useEffect(() => { if (ended && next) setAuto(AUTO_NEXT_SEC); }, [ended, next]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (auto == null) return;
|
|
|
|
|
|
|
|
if (auto <= 0) { goNext(); return; }
|
|
|
|
|
|
|
|
const id = setTimeout(() => setAuto((a) => (a == null ? null : a - 1)), 1000);
|
|
|
|
|
|
|
|
return () => clearTimeout(id);
|
|
|
|
|
|
|
|
}, [auto]);
|
|
|
|
|
|
|
|
|
|
|
|
const toggle = () => {
|
|
|
|
const toggle = () => {
|
|
|
|
const v = videoRef.current;
|
|
|
|
const v = videoRef.current;
|
|
|
|
@ -989,6 +1024,7 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
const full = () => { screenRef.current?.requestFullscreen?.().catch(() => { /* not allowed in this frame */ }); };
|
|
|
|
const full = () => { screenRef.current?.requestFullscreen?.().catch(() => { /* not allowed in this frame */ }); };
|
|
|
|
const onKey = (e: React.KeyboardEvent) => {
|
|
|
|
const onKey = (e: React.KeyboardEvent) => {
|
|
|
|
if ((e.target as HTMLElement).tagName === 'SELECT' || (e.target as HTMLElement).tagName === 'INPUT') return;
|
|
|
|
if ((e.target as HTMLElement).tagName === 'SELECT' || (e.target as HTMLElement).tagName === 'INPUT') return;
|
|
|
|
|
|
|
|
if (e.key === 'Escape' && auto != null) { setAuto(null); return; }
|
|
|
|
if (e.key === ' ') { e.preventDefault(); toggle(); } else if (e.key === 'ArrowLeft') seek(pos - 10); else if (e.key === 'ArrowRight') seek(pos + 10); else if (e.key === 'f') full(); else if (e.key === 'm' && videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
|
|
|
if (e.key === ' ') { e.preventDefault(); toggle(); } else if (e.key === 'ArrowLeft') seek(pos - 10); else if (e.key === 'ArrowRight') seek(pos + 10); else if (e.key === 'f') full(); else if (e.key === 'm' && videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const mark = (me?.phone || me?.email || viewer?.name || 'student').replace(/^(.{3}).*(.{2})$/, '$1•••$2');
|
|
|
|
const mark = (me?.phone || me?.email || viewer?.name || 'student').replace(/^(.{3}).*(.{2})$/, '$1•••$2');
|
|
|
|
@ -1000,11 +1036,20 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
{lesson.videoAssetId ? (
|
|
|
|
{lesson.videoAssetId ? (
|
|
|
|
<video ref={videoRef} src={ds.assetUrl(lesson.videoAssetId)} playsInline preload="metadata"
|
|
|
|
<video ref={videoRef} src={ds.assetUrl(lesson.videoAssetId)} playsInline preload="metadata"
|
|
|
|
onLoadedMetadata={(e) => { if (pos) e.currentTarget.currentTime = pos; }}
|
|
|
|
onLoadedMetadata={(e) => { if (pos) e.currentTarget.currentTime = pos; }}
|
|
|
|
onTimeUpdate={(e) => setPos(e.currentTarget.currentTime)} onPlay={() => setPlaying(true)} onPause={() => setPlaying(false)} onEnded={() => setPlaying(false)} />
|
|
|
|
onTimeUpdate={(e) => setPos(e.currentTarget.currentTime)} onPlay={() => { setPlaying(true); setEnded(false); setAuto(null); }} onPause={() => setPlaying(false)} onEnded={() => { setPlaying(false); setEnded(true); }} />
|
|
|
|
) : (
|
|
|
|
) : (
|
|
|
|
<iframe ref={frameRef} src={VIMEO_PLACEHOLDER} onLoad={vlisten} title={lessonTitle(lesson, locale)} allow="autoplay; fullscreen; picture-in-picture" allowFullScreen />
|
|
|
|
<iframe ref={frameRef} src={VIMEO_PLACEHOLDER} onLoad={vlisten} title={lessonTitle(lesson, locale)} allow="autoplay; fullscreen; picture-in-picture" allowFullScreen />
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{canSave && <span className="wm" aria-hidden>{mark}</span>}
|
|
|
|
{canSave && <span className="wm" aria-hidden>{mark}</span>}
|
|
|
|
|
|
|
|
{auto != null && next && <div className="p-upnext" role="status">
|
|
|
|
|
|
|
|
<span className="p-upnext-k">{t('player.upNext')}</span>
|
|
|
|
|
|
|
|
<strong>{lessonNumber(c, next.id)}. {lessonTitle(next, locale)}</strong>
|
|
|
|
|
|
|
|
<span className="p-upnext-n num" aria-hidden><svg viewBox="0 0 24 24" width="18" height="18"><circle cx="12" cy="12" r="10" /></svg>{t('player.autoNext', { n: auto })}</span>
|
|
|
|
|
|
|
|
<div className="p-upnext-go">
|
|
|
|
|
|
|
|
<button className="btn btn-accent" onClick={goNext}><Icon name="play" size={14} />{t('player.playNow')}</button>
|
|
|
|
|
|
|
|
<button className="btn btn-quiet" onClick={() => setAuto(null)}>{t('common.cancel')}</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>}
|
|
|
|
{!vimeo && <div className="controls">
|
|
|
|
{!vimeo && <div className="controls">
|
|
|
|
<input type="range" min={0} max={dur} step={1} value={Math.floor(pos)} onChange={(e) => seek(Number(e.target.value))} aria-label={`${clock(pos)} / ${clock(dur)}`} />
|
|
|
|
<input type="range" min={0} max={dur} step={1} value={Math.floor(pos)} onChange={(e) => seek(Number(e.target.value))} aria-label={`${clock(pos)} / ${clock(dur)}`} />
|
|
|
|
<div className="row">
|
|
|
|
<div className="row">
|
|
|
|
@ -1024,7 +1069,8 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>}
|
|
|
|
</div>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{vimeo && <p className="small muted">{t('player.demoVideo')}{canSave && !done && <> · <button className="link" onClick={() => { setPos(dur); posRef.current = dur; heartbeat(); }}>{t('player.markWatched')}</button></>}</p>}
|
|
|
|
{head}
|
|
|
|
|
|
|
|
{vimeo && <p className="small muted">{t('player.demoVideo')}{canSave && !done && <> · <button className="link" onClick={() => { setPos(dur); posRef.current = dur; heartbeat(); setEnded(true); }}>{t('player.markWatched')}</button></>}</p>}
|
|
|
|
{done && pct === 100 && (
|
|
|
|
{done && pct === 100 && (
|
|
|
|
<div className="course-done" role="status">
|
|
|
|
<div className="course-done" role="status">
|
|
|
|
<div className="confetti" aria-hidden>{Array.from({ length: 18 }, (_, k) => <i key={k} style={{ '--k': k } as React.CSSProperties} />)}</div>
|
|
|
|
<div className="confetti" aria-hidden>{Array.from({ length: 18 }, (_, k) => <i key={k} style={{ '--k': k } as React.CSSProperties} />)}</div>
|
|
|
|
@ -1037,7 +1083,7 @@ function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Les
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{done && pct < 100 && (
|
|
|
|
{done && pct < 100 && auto == null && (
|
|
|
|
<div className="lesson-done" role="status">
|
|
|
|
<div className="lesson-done" role="status">
|
|
|
|
<span className="ld-check" aria-hidden><svg viewBox="0 0 24 24" width="22" height="22"><path d="M5 12.5l4.5 4.5L19 7" /></svg></span>
|
|
|
|
<span className="ld-check" aria-hidden><svg viewBox="0 0 24 24" width="22" height="22"><path d="M5 12.5l4.5 4.5L19 7" /></svg></span>
|
|
|
|
<span className="ld-txt"><strong>{t('player.completed')}</strong><span className="small muted num">{t('player.courseProgress', { pct })}</span></span>
|
|
|
|
<span className="ld-txt"><strong>{t('player.completed')}</strong><span className="small muted num">{t('player.courseProgress', { pct })}</span></span>
|
|
|
|
|