Browse Source

Add missing null check before disconnecting source

Adam Scott 1 year ago
parent
commit
1776258b1c
1 changed files with 3 additions and 1 deletions
  1. 3 1
      platform/web/js/libs/library_godot_audio.js

+ 3 - 1
platform/web/js/libs/library_godot_audio.js

@@ -630,7 +630,9 @@ class SampleNode {
 	 * @returns {void}
 	 * @returns {void}
 	 */
 	 */
 	_restart() {
 	_restart() {
-		this._source.disconnect();
+		if (this._source != null) {
+			this._source.disconnect();
+		}
 		this._source = GodotAudio.ctx.createBufferSource();
 		this._source = GodotAudio.ctx.createBufferSource();
 		this._source.buffer = this.getSample().getAudioBuffer();
 		this._source.buffer = this.getSample().getAudioBuffer();