Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Related Plugin Resources
Index

The Media Capture API


Modern devices offer a huge range of media capabilities to the user; at present, people can record a video, record some audio, and take a picture, and use all of these media in their communication flow.

The Media Capture API works asynchronously as most of the PhoneGap APIs and provides access to the audio, image, and video capture capabilities of the device. In order to start working with this API, you have to install the plugin to your project as shown here:

$ phonegap plugin add cordova-plugin-media-capture

Once done, you can access the capture object stored in the navigator.device object:

var capture = navigator.device.capture;

Once you get access to the capture object, it's possible to detect which video, audio, and image formats are supported by the device through the following properties:

  • supportedAudioModes

  • supportedImageModes

  • supportedVideoModes

Each property returns an array of the ConfigurationData objects; each item of the array represents a supported media...