@sage-rsc/talking-head-react 1.0.61 → 1.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.js +951 -949
- package/package.json +1 -1
- package/src/components/TalkingHeadAvatar.jsx +13 -6
package/package.json
CHANGED
|
@@ -52,11 +52,17 @@ const TalkingHeadAvatar = forwardRef(({
|
|
|
52
52
|
const showFullAvatarRef = useRef(showFullAvatar);
|
|
53
53
|
const pausedSpeechRef = useRef(null); // Track paused speech for resume
|
|
54
54
|
const speechEndIntervalRef = useRef(null); // Track onSpeechEnd polling interval
|
|
55
|
+
const isPausedRef = useRef(false); // Track pause state for interval checks
|
|
55
56
|
const [isLoading, setIsLoading] = useState(true);
|
|
56
57
|
const [error, setError] = useState(null);
|
|
57
58
|
const [isReady, setIsReady] = useState(false);
|
|
58
59
|
const [isPaused, setIsPaused] = useState(false);
|
|
59
60
|
|
|
61
|
+
// Keep ref in sync with state
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
isPausedRef.current = isPaused;
|
|
64
|
+
}, [isPaused]);
|
|
65
|
+
|
|
60
66
|
// Update ref when prop changes
|
|
61
67
|
useEffect(() => {
|
|
62
68
|
showFullAvatarRef.current = showFullAvatar;
|
|
@@ -311,8 +317,8 @@ const TalkingHeadAvatar = forwardRef(({
|
|
|
311
317
|
checkInterval = setInterval(() => {
|
|
312
318
|
checkCount++;
|
|
313
319
|
|
|
314
|
-
// Don't fire callback if paused
|
|
315
|
-
if (
|
|
320
|
+
// Don't fire callback if paused (check ref for current value)
|
|
321
|
+
if (isPausedRef.current) {
|
|
316
322
|
return;
|
|
317
323
|
}
|
|
318
324
|
|
|
@@ -323,7 +329,7 @@ const TalkingHeadAvatar = forwardRef(({
|
|
|
323
329
|
checkInterval = null;
|
|
324
330
|
speechEndIntervalRef.current = null;
|
|
325
331
|
}
|
|
326
|
-
if (!callbackFired && !
|
|
332
|
+
if (!callbackFired && !isPausedRef.current) {
|
|
327
333
|
callbackFired = true;
|
|
328
334
|
try {
|
|
329
335
|
options.onSpeechEnd();
|
|
@@ -348,18 +354,18 @@ const TalkingHeadAvatar = forwardRef(({
|
|
|
348
354
|
audioPlaylistEmpty &&
|
|
349
355
|
talkingHead.isAudioPlaying === false;
|
|
350
356
|
|
|
351
|
-
if (isFinished && !callbackFired && !
|
|
357
|
+
if (isFinished && !callbackFired && !isPausedRef.current) {
|
|
352
358
|
// Double-check after a small delay to ensure it's really finished
|
|
353
359
|
setTimeout(() => {
|
|
354
360
|
// Re-check one more time to be sure, and make sure we're still not paused
|
|
355
361
|
const finalCheck = talkingHead &&
|
|
356
|
-
!
|
|
362
|
+
!isPausedRef.current &&
|
|
357
363
|
talkingHead.isSpeaking === false &&
|
|
358
364
|
(!talkingHead.speechQueue || talkingHead.speechQueue.length === 0) &&
|
|
359
365
|
(!talkingHead.audioPlaylist || talkingHead.audioPlaylist.length === 0) &&
|
|
360
366
|
talkingHead.isAudioPlaying === false;
|
|
361
367
|
|
|
362
|
-
if (finalCheck && !callbackFired && !
|
|
368
|
+
if (finalCheck && !callbackFired && !isPausedRef.current) {
|
|
363
369
|
callbackFired = true;
|
|
364
370
|
if (checkInterval) {
|
|
365
371
|
clearInterval(checkInterval);
|
|
@@ -437,6 +443,7 @@ const TalkingHeadAvatar = forwardRef(({
|
|
|
437
443
|
|
|
438
444
|
// Pause the speaking
|
|
439
445
|
talkingHeadRef.current.pauseSpeaking();
|
|
446
|
+
isPausedRef.current = true;
|
|
440
447
|
setIsPaused(true);
|
|
441
448
|
}
|
|
442
449
|
}
|