mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: english audio again (#54696)
This commit is contained in:
@@ -13,6 +13,10 @@ const sToMs = (n: number) => {
|
||||
return n * 1000;
|
||||
};
|
||||
|
||||
const loadImage = (src: string | null) => {
|
||||
if (src) new Image().src = src;
|
||||
};
|
||||
|
||||
export function Scene({
|
||||
scene,
|
||||
isPlaying,
|
||||
@@ -25,27 +29,20 @@ export function Scene({
|
||||
const { t } = useTranslation();
|
||||
const { setup, commands } = scene;
|
||||
const { audio, alwaysShowDialogue } = setup;
|
||||
const { startTimestamp, finishTimestamp } = audio;
|
||||
const { startTimestamp = null, finishTimestamp = null } = audio;
|
||||
|
||||
const audioTimestamp =
|
||||
startTimestamp !== null && finishTimestamp !== null
|
||||
? `#t=${startTimestamp}`
|
||||
: '';
|
||||
|
||||
const hasTimestamps = startTimestamp && finishTimestamp;
|
||||
// if there are timestamps, we use the difference between them as the duration
|
||||
// if not, we assume we're playing the whole audio file.
|
||||
const duration = hasTimestamps
|
||||
? sToMs(finishTimestamp - startTimestamp)
|
||||
: Infinity;
|
||||
const hasTimestamps = startTimestamp !== null && finishTimestamp !== null;
|
||||
const audioTimestamp = hasTimestamps ? `#t=${startTimestamp}` : '';
|
||||
|
||||
const audioRef = useRef<HTMLAudioElement>(
|
||||
new Audio(`${sounds}/${audio.filename}${audioTimestamp}`)
|
||||
);
|
||||
|
||||
const loadImage = (src: string | null) => {
|
||||
if (src) new Image().src = src;
|
||||
};
|
||||
// if there are timestamps, we use the difference between them as the duration
|
||||
// if not, we assume we're playing the whole audio file.
|
||||
const duration = hasTimestamps
|
||||
? sToMs(finishTimestamp - startTimestamp)
|
||||
: Infinity;
|
||||
|
||||
// on mount
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user