Cc.audioEngine.stopEffect(): Android parameter problem

I use cocos2d-x 3.8.

I get an id from the playEffect function:

effect.id = cc.audioEngine.playEffect();

This is an object, other than stated in the documentation, where it is just an id (like its name).
When I stop this effect using

 cc.audioEngine.stopEffect(effect.id);

I get no problems with HTML, but with Android following message:

jsb: ERROR: File /var/www/html/21words/frameworks/runtime-src/proj.android/…/…/cocos2d-x/cocos/scripting/js-bindings/proj.android/…/auto/jsb_cocos2dx_auto.cpp: Line: 69578, Function: js_cocos2dx_SimpleAudioEngine_stopEffect

In the ccp code it seems clear to me what happens (line 69577):

ok &= jsval_to_uint32(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_stopEffect : Error processing arguments");

It checks the paarameter if it is a uint32, but it is an object. Which side is wrong: the js-object or the cpp uint32?

But if you pass effect.id, it will not be an object anymore. Or there is something am I missing?
You could try cc.audioEngine.stopEffect(parseInt(effect.id)) in case effect.id is a string.

@lavizrap how did you get error message from Android? I’ve tried Cocos IDE and it failed to debug most of the time. Thanks for sharing. :slight_smile:

@StudioAMK

I debug with cocos ide, just using the button for it if the sdk are configured it should work. If you want, start a new post and we try to figure out what’s going on.

@StudioAMK The string value of an object is [object object]. I cannot pass that to a function that expects and int.

@alexgg I use the command line command “cocos” and the “adb” command of Android: (adb logcat | grep cocos2d gives you all you need :wink:

1 Like