@luna-editor/engine 0.5.14 → 0.5.15
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/Player.js +10 -24
- package/dist/hooks/usePreloadImages.js +19 -0
- package/package.json +1 -1
package/dist/Player.js
CHANGED
|
@@ -465,30 +465,6 @@ export const Player = ({ scenario: scenarioProp, settings, plugins = EMPTY_PLUGI
|
|
|
465
465
|
});
|
|
466
466
|
// パートボイス再生
|
|
467
467
|
const { playVoice, stopVoice } = useVoice();
|
|
468
|
-
// currentBlockが変更されたらパートボイスを再生
|
|
469
|
-
useEffect(() => {
|
|
470
|
-
var _a;
|
|
471
|
-
if (!isFirstRenderComplete)
|
|
472
|
-
return;
|
|
473
|
-
if (!currentBlock)
|
|
474
|
-
return;
|
|
475
|
-
if (state.isEnded)
|
|
476
|
-
return;
|
|
477
|
-
if ((currentBlock.blockType === "dialogue" ||
|
|
478
|
-
currentBlock.blockType === "narration") &&
|
|
479
|
-
((_a = currentBlock.partVoice) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
480
|
-
playVoice(currentBlock.partVoice.url);
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
stopVoice();
|
|
484
|
-
}
|
|
485
|
-
}, [
|
|
486
|
-
currentBlock,
|
|
487
|
-
isFirstRenderComplete,
|
|
488
|
-
state.isEnded,
|
|
489
|
-
playVoice,
|
|
490
|
-
stopVoice,
|
|
491
|
-
]);
|
|
492
468
|
// 会話分岐機能
|
|
493
469
|
const branchNavigatorRef = useRef(new BranchNavigator());
|
|
494
470
|
const conversationBranch = useConversationBranch({
|
|
@@ -572,6 +548,14 @@ export const Player = ({ scenario: scenarioProp, settings, plugins = EMPTY_PLUGI
|
|
|
572
548
|
const isContinuableBlock = currentBlock.blockType === "dialogue" ||
|
|
573
549
|
currentBlock.blockType === "narration";
|
|
574
550
|
const doTyping = () => {
|
|
551
|
+
var _a;
|
|
552
|
+
// パートボイス再生(テキスト表示と同時)
|
|
553
|
+
if (isContinuableBlock && ((_a = currentBlock.partVoice) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
554
|
+
playVoice(currentBlock.partVoice.url);
|
|
555
|
+
}
|
|
556
|
+
else if (isContinuableBlock) {
|
|
557
|
+
stopVoice();
|
|
558
|
+
}
|
|
575
559
|
if (continueMode && isContinuableBlock) {
|
|
576
560
|
startTyping(content, continueMode);
|
|
577
561
|
}
|
|
@@ -597,6 +581,8 @@ export const Player = ({ scenario: scenarioProp, settings, plugins = EMPTY_PLUGI
|
|
|
597
581
|
resetTypewriter,
|
|
598
582
|
isFirstRenderComplete,
|
|
599
583
|
pluginsLoaded,
|
|
584
|
+
playVoice,
|
|
585
|
+
stopVoice,
|
|
600
586
|
]);
|
|
601
587
|
// 分岐ブロック自動ロード処理
|
|
602
588
|
useEffect(() => {
|
|
@@ -3,6 +3,25 @@ export const usePreloadImages = (scenario) => {
|
|
|
3
3
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
4
4
|
// プリロード済みの画像URLセットを追跡(シナリオ変更で再プリロードを避ける)
|
|
5
5
|
const preloadedUrlsRef = useRef(new Set());
|
|
6
|
+
// プリロード済みの音声URLセットを追跡
|
|
7
|
+
const preloadedAudioUrlsRef = useRef(new Set());
|
|
8
|
+
// パートボイスをプリロード
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const voiceUrls = new Set();
|
|
11
|
+
scenario.blocks.forEach((block) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if ((_a = block.partVoice) === null || _a === void 0 ? void 0 : _a.url) {
|
|
14
|
+
voiceUrls.add(block.partVoice.url);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const newVoiceUrls = Array.from(voiceUrls).filter((url) => !preloadedAudioUrlsRef.current.has(url));
|
|
18
|
+
for (const url of newVoiceUrls) {
|
|
19
|
+
const audio = new Audio();
|
|
20
|
+
audio.preload = "auto";
|
|
21
|
+
audio.src = url;
|
|
22
|
+
preloadedAudioUrlsRef.current.add(url);
|
|
23
|
+
}
|
|
24
|
+
}, [scenario]);
|
|
6
25
|
useEffect(() => {
|
|
7
26
|
const imageUrls = new Set();
|
|
8
27
|
// シナリオ全体から画像URLを収集
|