In this task, you'll be introduced to the Media API and will create a class that our audio notes can use to interact with the Media API. We'll call this a media manager.
Before going any further, you should add the Media plugin to the project:
cordova plugin add org.apache.cordova.media
Although we'll be covering the majority of the Media API, it's always best to consult the Cordova documentation to ensure you're seeing the most up-to-date information. You should be able to see the documentation on the Media API at https://github.com/apache/cordova-plugin-media/blob/dev/doc/index.md.
As with the File API, the Media API is based on callbacks, though thankfully, not to the same extent. We can interact with most of the API in a synchronous fashion, but there are a few areas that work asynchronously.
To instantiate a Media
object, you can do the following:
var myMedia = new Media ( pathToFile, success, error, status );
Let's look at each of these...