diff --git a/src/components/sections/ArticleSection.tsx b/src/components/sections/ArticleSection.tsx index e8ca5dd..4125b0d 100644 --- a/src/components/sections/ArticleSection.tsx +++ b/src/components/sections/ArticleSection.tsx @@ -8,6 +8,8 @@ import { useVisitor } from '@/context/VisitorContext' import { t, tPlain } from '@/lib/i18n' import type { ContentDTO, SectionDTO } from '@/lib/api/types' import AppBar from '@/components/ui/AppBar' +import NarratorAvatar from '@/components/ui/NarratorAvatar' +import { useAudioResource } from '@/hooks/useAudioResource' import { trackEvent } from '@/lib/stats' interface Props { @@ -15,9 +17,10 @@ interface Props { slug: string configId: string languages: string[] + apiKey: string } -export default function ArticleSection({ section, configId, languages }: Props) { +export default function ArticleSection({ section, configId, languages, apiKey }: Props) { const { language, setAvailableLanguages, instanceId } = useVisitor() const back = useBack() const article = section.article @@ -60,8 +63,11 @@ export default function ArticleSection({ section, configId, languages }: Props) return () => el.removeEventListener('scroll', onScroll) }, [instanceId, configId, section.id, language, isLandscape]) - const audioUrl = article?.audioIds?.find((a) => a.language === language)?.value - ?? article?.audioIds?.[0]?.value + const audio = useAudioResource( + article?.audioIds?.find((a) => a.language === language)?.value ?? article?.audioIds?.[0]?.value, + apiKey, + ) + const audioUrl = audio.url useEffect(() => { if (article?.isReadAudioAuto && audioRef.current) { @@ -131,7 +137,9 @@ export default function ArticleSection({ section, configId, languages }: Props) )}
- GUIDE AUDIO + {audio.narratorName + ? + : GUIDE AUDIO} {!isAudioCompact && (
diff --git a/src/components/sections/ParcoursSection.tsx b/src/components/sections/ParcoursSection.tsx index 4c2d445..cc0cad7 100644 --- a/src/components/sections/ParcoursSection.tsx +++ b/src/components/sections/ParcoursSection.tsx @@ -4,6 +4,8 @@ import { useEffect, useRef, useState } from 'react' import { useBack } from '@/hooks/useBack' import ChevronLeft from '@/components/ui/ChevronLeftIcon' import ResourceViewer, { isImageResource } from '@/components/ui/ResourceViewer' +import NarratorAvatar from '@/components/ui/NarratorAvatar' +import { useAudioResource } from '@/hooks/useAudioResource' import { useVisitor } from '@/context/VisitorContext' import { useIsLandscape, useMediaQuery } from '@/hooks/useOrientation' import FloatingPanel from '@/components/ui/FloatingPanel' @@ -37,7 +39,7 @@ interface Props { type View = 'list' | 'start' | 'progress' | 'end' -export default function ParcoursSection({ section, languages }: Props) { +export default function ParcoursSection({ section, languages, apiKey }: Props) { const { language, setAvailableLanguages } = useVisitor() const back = useBack() @@ -130,6 +132,7 @@ export default function ParcoursSection({ section, languages }: Props) { if (useMapView) { return ( a.language === language)?.value - ?? currentStep?.audioIds?.[0]?.value - const audioUrl = audioUrlRaw?.startsWith('http') ? audioUrlRaw : undefined + const audio = useAudioResource( + currentStep?.audioIds?.find((a) => a.language === language)?.value ?? currentStep?.audioIds?.[0]?.value, + apiKey, + ) + const audioUrl = audio.url const stepContents = [...(currentStep?.contents ?? [])].sort((a, b) => (a.order ?? 0) - (b.order ?? 0)) const hasCarousel = stepContents.length > 0 @@ -875,6 +882,11 @@ function ParcoursMapProgression({ path, steps, stepIndex, completedSteps, primar border: `1px solid ${isGame ? 'rgba(212,175,55,0.2)' : '#E8E3DA'}`, }} > + {audio.narratorName && ( +
+ +
+ )}