sdk for webのsampleを使ってリップシンクと音声再生を行いたいです。
1.SDK/Samples/TypeScript/Demo/srcで新しくTSファイルを作成し、subdelegateのインスタンスを作成
2.インスタンスからlapplive2dmanagerを取得
3.イベントリスナで呼び出す
上記のようなことを行いましたが、
関数を呼び出すと再読込され、肝心のリップシンク・音声再生が行われません。
1度読み込んだ後再読込せず、playVoiceを実行できる方法はあるのか知りたいです。
また、代替案についても、もし良ければご教授願いたいです。
何卒よろしくお願いします。
以下、コードです
------------------------------------------------
//script.ts
import { LAppLive2DManager } from "./lapplive2dmanager";
import { LAppSubdelegate } from "./lappsubdelegate";
const lappsubdelegate = new LAppSubdelegate;
const lapplive2dmanager = lappsubdelegate.getLive2DManager();
var onProcessCompleted = function () {
lapplive2dmanager.playVoice()
}
button.addEventListener('click', () => {
onProcessCompleted()
})
------------------------------------------------
//lapplive2dmanager.ts
export class LAppLive2DManager {
/* 省略 */
public playVoice() {
for (let i = 0; i < this._models.getSize(); i++) {
let filePath = "./Resources/Haru/sounds/haru_Info_04.wav";
const myRequest = new Request(filePath);
fetch(myRequest)
.then((response) => response.blob())
.then((myBlob) => {
const url = window.URL.createObjectURL(myBlob);
const voice: any = document.getElementById("voice");
voice.src = url;
if (i == 0) {
voice.play();
}
this._models.at(i)._wavFileHandler.start(url);
});
}
}
}
------------------------------------------------