Skip to content

Commit a7646c2

Browse files
committed
🐛 fix: play error
1 parent 11d55af commit a7646c2

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/features/DanceList/Item/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const DanceItem = (props: DanceItemProps) => {
4949
viewer.model?.disposeAll();
5050
if (isPlaying && isCurrentPlay) {
5151
setIsPlaying(false);
52+
viewer.model?.loadIdleAnimation();
5253
} else {
5354
setCurrentPlayId(danceItem.danceId);
5455
setIsPlaying(true);

src/features/audioPlayer/audioPlayer.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ export class AudioPlayer {
77
this.bufferSource = undefined;
88
}
99

10-
public async playFromArrayBuffer(
11-
buffer: ArrayBuffer,
12-
onEnded?: () => void,
13-
onProgress?: () => void,
14-
) {
10+
public async playFromArrayBuffer(buffer: ArrayBuffer, onEnded?: () => void) {
1511
const audioBuffer = await this.audio.decodeAudioData(buffer);
1612

1713
this.bufferSource = this.audio.createBufferSource();
@@ -22,9 +18,6 @@ export class AudioPlayer {
2218
if (onEnded) {
2319
this.bufferSource.addEventListener('ended', onEnded);
2420
}
25-
if (onProgress) {
26-
this.bufferSource.addEventListener('time', onProgress);
27-
}
2821
}
2922

3023
public stopPlay() {

src/libs/vrmViewer/model.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,10 @@ export class Model {
163163
const clip = await loadVMDAnimation(danceUrl, vrm);
164164
const action = mixer.clipAction(clip);
165165
action.setLoop(LoopOnce, 1).play(); // play animation
166-
if (audioUrl) {
167-
this._audioPlayer?.playFromURL(audioUrl, () => {
168-
onEnd?.();
169-
});
170-
this._audio = audioUrl;
171-
}
166+
this._audioPlayer?.playFromURL(audioUrl, () => {
167+
onEnd?.();
168+
});
169+
this._audio = audioUrl;
172170

173171
this._action = action;
174172
this._clip = clip;

0 commit comments

Comments
 (0)