I am using cordova-media-plugin 1.0.1. in an Ionic mobile app. I am using the plugin to play the audio file.
I am able to get it to play using:
After digging into this deeper, I have found that (despite the documentation) callbacks are not implemented for iOS in version 1.0.1 of the cordova-media-plugin. They are implemented for Android, FireOS, and Windows ONLY.
At the bottom of the Media.js file in the module's www directory, it creates a cordova channel which lets it subscribe to messages from the native player. Unfortunately, that code is only executed for android, fireos, and windows phone:
if (cordova.platformId === 'android' || cordova.platformId === 'amazon-fireos' || cordova.platformId === 'windowsphone') {
var channel = require('cordova/channel');
channel.createSticky('onMediaPluginReady');
channel.waitForInitialization('onMediaPluginReady');
channel.onCordovaReady.subscribe(function() {
exec(onMessageFromNative, undefined, 'Media', 'messageChannel', []);
channel.initializationComplete('onMediaPluginReady');
});
}
I tried adding ios to the list to see if it was just a miss in that code and it blew up:
ERROR: Method 'messageChannel:' not defined in Plugin 'Media'
So... those of us building for iOS or other non-Android/Windows platforms are SOL when it comes to callbacks (though playing still works). There seems to be no way to submit a bug report to Apache about this unless it is an email coming from an apache.org email address, so I am not sure they even know about it.