Okay, so far so good. But when launch this on my iPhone with the Meteor run ios-device, and click the button which should play the sound stored in my Public folder, I get the following error:
Unkown f*in Resource…
For reference, this Stack Overflow question was my guiding light:
Has anyone managed to get a sound to play in a Meteor-Cordova app? And if so, how did you do it? Am I doing something fundamentally stupid?
As far as I can see, you’re trying to load a resource with a file:// URL. AFAIK, this is not supported by Meteor. Meteor uses its own protocol to load files on the local device, using a meteor:local scheme. I think this has something to do with their hot code reload process.
I haven’t used the cordova-plugin-media, but looking at the file path in the error message it seems ...Study%20Cake.app/www/application/assets/audio/blop2.wav should be ...Study%20Cake.app/www/application/app/assets/audio/blop2.wav (note the extra app directory). So I’m assuming changing your code to playSound('/app/assets/audio/blop2.wav') might work.
Its very easy to play audio on mobile devices once you know where and how to look for the files. Unfortunately Cordova doesn’t give you a very good answer on how to do this. This keeps coming up on the forums. I feel like there needs to a be a blurb in the cordova - meteor integration wiki.
We’ve recently started a project to work on better documentation in the form of Meteor guides. Accessing files in Cordova seems like a great topic to add. Could you contribute your findings to https://github.com/meteor/guide/issues/40?