Why am I getting an Illegal invocation error from cordova media plugin? -


this code running:

var clicker = new media("sounds/click.wav", function(){ console.log("playing click"); }, console.log); clicker.play(); 

i copied documentation, assumed work, when try , run error:

i/mediafocuscontrol( 1486):  audiofocus  requestaudiofocus() android.media.audiomanager@21802acforg.apache.cordova.media.audiohandler$1@3bb77c5c req=1flags=0x0 i/chromium( 3671): [info:console(312)] "error in success callbackid: media1544259360 : typeerror: illegal invocation", source: file:///android_asset/www/cordova.js (312) 

what causes error? i've tried variety of different success callback functions, , none of them worked, suspect maybe due misconfiguration somewhere entirely separate, have no idea how track down.

it turns out there 2 problems: first, needed change file path /android_asset/www/sounds/beep.mp3. had tried though, , dismissed because didn't work... due second problem: cordova media plugin cannot play wav files. after converting file mp3, worked perfectly.

leaving benefit of future visitors: important takeaway that

a) "illegal invocation" can mean "invalid or missing file"

b) media files must in mp3 format, not wav.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -