Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by Joncom

Every new audio file loaded after the game has started will throw an error.

I've posted a code example on Github:
https://github.com/Joncom/impact-audio-bug

But in a nutshell, after the game has loaded, calling

var sound = new ig.Sound('media/example.*');

will always throw the error
Uncaught TypeError: loadCallback is not a function (line 86 of sound.js)

8 years ago by AndrewMast

Line 86 of sound.js is part of ig.SoundManager's loadWebAudio function:
65	loadWebAudio: function( path, multiChannel, loadCallback ) {
66		// Path to the soundfile with the right extension (.ogg or .mp3)
67		var realPath = ig.prefix + path.replace(/[^\.]+$/, this.format.ext) + ig.nocache;
68
69		if( this.clips[path] ) {
70			return this.clips[path];
71		}
72
73		var audioSource = new ig.Sound.WebAudioSource()
74		this.clips[path] = audioSource;
75
76		var request = new XMLHttpRequest();
77		request.open('GET', realPath, true);
78		request.responseType = 'arraybuffer';
79
80
81		var that = this;
82		request.onload = function(ev) {
83			that.audioContext.decodeAudioData(request.response, 
84				function(buffer) {
85					audioSource.buffer = buffer;
86					loadCallback( path, true, ev );
87				}, 
88				function(ev) {
89					loadCallback( path, false, ev );
90				}
91			);
92		};
93		request.onerror = function(ev) {
94			loadCallback( path, false, ev );
95		};
96		request.send();
97
98		return audioSource;
99	}

My guess is that it is being caused by line 231:
231		var track = ig.soundManager.load(path, false);

(Note that no loadCallback function is being passed)

I think Dominic should add: loadCallback = loadCallback || function() {}; between lines 65 and 66.

I wish Dominic had a private GitHub repository for ImpactJS that he adds only the people who have already bought it.

-Andrew

8 years ago by Joncom

My bad, it seems this issue was fixed November 16, 2014, in commit 6743350c98d939c185542f028f220f97d89f0153. However, that's after the release of Impact version 1.24, so I think the most recently released zip file excludes the fix.

7 years ago by Fravio4

Hi, what doing those funktion?
var that = this;
82 request.onload = function(ev) {
83 that.audioContext.decodeAudioData(request.response,
84 function(buffer) {
85 audioSource.buffer = buffer;
86 loadCallback( path, true, ev );
87 },
88 function(ev) {
89 loadCallback( path, false, ev );
90 }
91 );
92 };
Page 1 of 1
« first « previous next › last »