I’ve tried on Chrome (Version 77.0.3865.90 (Official Build) (64-bit)) and Safari (Version 13.0.1) on Mac.
I’m basically trying to play a sound in the browser.
Any ideas?
Here’s my code:
function main () {
var result
var outval = {}
result = FMOD.System_Create(outval)
if (result !== FMOD.OK) {
console.log('result:', result)
}
}
var FMOD = {}; // FMOD global object which must be declared to enable 'main' and 'preRun' and then call the constructor function.
FMOD['onRuntimeInitialized'] = main; // Called when the Emscripten runtime has initialized
FMOD['TOTAL_MEMORY'] = 64 * 1024 * 1024; // (ASM.JS ONLY) FMOD Heap defaults to 16mb which is enough for this demo, but set it differently here for demonstration (64mb)
FMODModule(FMOD); // Calling the constructor function with our object
you can ignore that. it is from the logging version and not actually asserting. its due to the no thread / cross platform port of the code. I can look into ifdeffing out that assert.
Use the non ‘L’ version by the way for better performance.
I’ve tried to ignore the assert, but still no sound is playing. I had a warning saying:
warning: browser could not fully decode audio /ocean.wav, trying slower base64 approach
So I’ve encoded the file in m4a, now the warning disappeared but it seems like FMOD is having a hard time using it, because when I call System.createSound, it doesn’t give me a valid Sound object, in fact it’s giving me an undefined object.
function prerun () {
FMOD.FS_createPreloadedFile(
'/',
'ocean.m4a',
'sounds/',
true,
false,
)
}
function main () {
var result
var outval = {}
result = FMOD.System_Create(outval)
if (result !== FMOD.OK) {
console.log('result:', result)
}
var System = outval.val
var outval2 = {}
System.createSound('/sounds/ocean.m4a', FMOD.LOOP_OFF, null, outval2)
var Ocean = outval2.val
console.log('result:', Ocean)
System.playSound(Ocean, null, false, null)
}
var FMOD = {}; // FMOD global object which must be declared to enable 'main' and 'preRun' and then call the constructor function.
FMOD['preRun'] = prerun; // Will be called because FMOD runs, but after the Emscripten runtime has initialized
FMOD['onRuntimeInitialized'] = main; // Called when the Emscripten runtime has initialized
FMOD['TOTAL_MEMORY'] = 64 * 1024 * 1024; // (ASM.JS ONLY) FMOD Heap defaults to 16mb which is enough for this demo, but set it differently here for demonstration (64mb)
FMODModule(FMOD); // Calling the constructor function with our object
Hi Brett, I’m having the same issue as Janick, but I’m trying to play a sound from an https source and the examples don’t provide any example for this. Issue is happening when I’m calling System.createStream :
let soundOut: any = {};
result = system.createStream('https://cdn2.ipnoscloud.com/streams/web/test.mp3', FMOD.LOOP_NORMAL, null, soundOut);
which results in this output from fmodL.js :
[LOG] SystemI::createSoundInternal : Create name='https://cdn2.ipnoscloud.com/streams/web/test.mp3', mode=0x00000082
fmod.service.ts:13 fmod error: A command issued was not supported by this object. Possibly a plugin without certain callbacks specified. code 68
when the port was done access to sockets werent really available, but it looks like they have been added recently. If it blocks due to no threads, then yes that would be pretty bad. It wraps websockets by the look of it , we’d have to do some testing on this side to see how well it works.