1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-04 17:04:49 +00:00

Fix Web samples finished missing signal

This commit is contained in:
Adam Scott
2024-07-07 13:31:56 -04:00
parent f3af22b10b
commit a38f30fbd5
6 changed files with 61 additions and 2 deletions

View File

@@ -687,9 +687,15 @@ class SampleNode {
}
switch (self.getSample().loopMode) {
case 'disabled':
case 'disabled': {
const id = this.id;
self.stop();
break;
if (GodotAudio.sampleFinishedCallback != null) {
const idCharPtr = GodotRuntime.allocString(id);
GodotAudio.sampleFinishedCallback(idCharPtr);
GodotRuntime.free(idCharPtr);
}
} break;
case 'forward':
case 'backward':
self.restart();
@@ -1090,6 +1096,12 @@ const _GodotAudio = {
busSolo: null,
Bus,
/**
* Callback to signal that a sample has finished.
* @type {(playbackObjectIdPtr: number) => void | null}
*/
sampleFinishedCallback: null,
/** @type {AudioContext} */
ctx: null,
input: null,
@@ -1764,6 +1776,17 @@ const _GodotAudio = {
godot_audio_sample_bus_set_mute: function (bus, enable) {
GodotAudio.set_sample_bus_mute(bus, Boolean(enable));
},
godot_audio_sample_set_finished_callback__proxy: 'sync',
godot_audio_sample_set_finished_callback__sig: 'vi',
/**
* Sets the finished callback
* @param {Number} callbackPtr Finished callback pointer
* @returns {void}
*/
godot_audio_sample_set_finished_callback: function (callbackPtr) {
GodotAudio.sampleFinishedCallback = GodotRuntime.get_func(callbackPtr);
},
};
autoAddDeps(_GodotAudio, '$GodotAudio');