The Cordova Media API provides applications with the ability to record and play audio files from within a Cordova application. With this API, there is some overlap with the capabilities of the Capture API described in Chapter 3. The Capture API allows you to only record audio files using the built-in Voice Recorder application, while the Media API will play and record audio files from directly within the Cordova application’s UI. The documentation for the Media API indicates that the API doesn’t follow the capture standard and warns developers that future development will be around the Capture API.

That being said, there’s still some usefulness for this API. Even though the Capture API allows you to capture audio files, duplicating the same functionality provided in the Media API, the Capture API doesn’t provide a mechanism to play audio files, so you’ll need the Media API to do that.

An application would use this API to play audio files while the application is running. This is primarily used by games; used as a mechanism for playing a soundtrack and in-game sounds as the game is played. You can also use this API to record voice notes and automatically attach them to some information in a Customer Relationship Management (CRM) application for example.

Sample applications are included that illustrate how to play audio files using this API. I ran into a lot of cross-platform issues with this particular application, so there’s a lot of good content in the chapter that describes everything. Another application highlighted in the chapter illustrates how to record audio files using the API.