diff --git a/src/js/components/Stream.tsx b/src/js/components/Stream.tsx index 742a81e..c8a7f4d 100644 --- a/src/js/components/Stream.tsx +++ b/src/js/components/Stream.tsx @@ -23,8 +23,10 @@ export function Stream({ reciter, surah, stream, locale, slice, endOfStream, isP { 'overflowY': 'auto' } : { 'overflowY': 'hidden' }; const audioRef = useRef(null); + const { url: baseUrl } = reciter; + const ayah = stream[stream.length-1]; + const src = `${baseUrl}/${surah.id}/${ayah.id}.mp3`; const ayat = stream.map((ayah: Quran.Ayah) => { - const { url: baseUrl } = reciter; return (
  • @@ -35,12 +37,10 @@ export function Stream({ reciter, surah, stream, locale, slice, endOfStream, isP {formatNumber(ayah.id, locale)}

    {ayah.text}

    -
  • ); }); - useEffect(() => { const ul: HTMLElement = document.querySelector('ul.stream')!; if (slice.coversOneAyah) { @@ -63,9 +63,19 @@ export function Stream({ reciter, surah, stream, locale, slice, endOfStream, isP } }, [stream, isPaused, soundOn]); + useEffect(() => { + const audio = audioRef.current; + if (audio) { + audio.addEventListener('ended', () => { + audio.setAttribute('src', src); + }); + } + }, [audioRef.current]); + return ( ); }