Skip to content

소리 관련 블럭에서 대기할 때 일시정지한 동안의 시간도 포함하는 오류 해결 #2921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/playground/blocks/block_sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,10 @@ module.exports = {
script.playState = 1;
const instance = Entry.Utils.playSound(sound.id);
Entry.Utils.addSoundInstances(instance, sprite);
const duration = Math.floor(
(sound.duration * 1000) / Entry.playbackRateValue
);
setTimeout(() => {

instance.on('complete', () => {
script.playState = 0;
}, duration);
});
}
return script;
} else if (script.playState == 1) {
Expand Down Expand Up @@ -381,14 +379,13 @@ module.exports = {
const sound = sprite.parent.getSound(soundId);
if (sound) {
script.playState = 1;
const instance = Entry.Utils.playSound(sound.id);
const duration = script.getNumberValue('SECOND', script) * 1000;
const instance = Entry.Utils.playSound(sound.id, { duration });
Entry.Utils.addSoundInstances(instance, sprite);
const timeValue = script.getNumberValue('SECOND', script);
setTimeout(() => {
instance.stop();

instance.on('complete', () => {
script.playState = 0;
}, timeValue * 1000);
instance.addEventListener('complete', (e) => {});
});
}
return script;
} else if (script.playState == 1) {
Expand Down Expand Up @@ -498,9 +495,9 @@ module.exports = {
});
Entry.Utils.addSoundInstances(instance, sprite);

setTimeout(() => {
instance.on('complete', () => {
script.playState = 0;
}, duration);
});
}
return script;
} else if (script.playState == 1) {
Expand Down