TL; dg
Install the media cord meteor add cordova: org.apache.cordova.media@0.2.15
Add audio files to the shared directory
Use /android_asset/www/application/path/to/sound.wav
If you look into this folder in your project,
$PROJECT_ROOT/.meteor/local/cordova-build/platforms/android/assets/www/
You will see your application as a cordova built for android.
Using the Cordova Media plugin, I tried to use the path to the /android_asset/www/path/to/sound.wav file /android_asset/www/path/to/sound.wav no avail.
# Install the cordova media plugin with this command meteor add cordova: org.apache.cordova.media@0.2.15
Instead, I saw that my sounds folder was inside the www directory, but in the application directory. So this file path has ended for me,
/android_asset/www/application/path/to/sound.wav
Here is the relevant code that worked for me.
function getMediaUrl(sound) { if (device.platform.toLowerCase() === "android") { return cordova.file.applicationDirectory.replace('file://', '') + 'www/application/' + sound.substr(1); } else { return cordova.file.applicationDirectory.replace('file://', '') + sound.substr(1); } } function playSound(sound) { return new Media( getMediaUrl(sound), function (success) {
NOTE I have included my audio files in the ie shared folder
$PROJECT_ROOT/public/sounds/test.wav
and on Android, this file path is translated to
/android_asset/www/application/sounds/test.wav
allen
source share