Release of PhoneGap Media Stream!

Simon MacDonald
PhoneGap
Published in
2 min readAug 15, 2017

We’re happy to announce the release of the new PhoneGap Media Stream plugin with support for iOS and Android!

The Media Stream plugin implements the W3C Media Capture API which allows authorized applications to access streams from the device’s audio and video capturing interfaces. The streams exposed by the API can be bound directly to the HTML <audio> or <video> elements or read and manipulated in the code, including further more specific processing via Image Capture API provided by phonegap-plugin-image-capture or the Media Recorder API provided by phonegap-plugin-media-recorder.

Accept permission to record audio
Accept permission to record video
Video tag shows live stream from camera

Media Stream Plugin Installation Instructions

After you have built your project, install the plugin in your project location:

$ phonegap plugin add phonegap-plugin-media-stream

(or)

$ cordova plugin add phonegap-plugin-media-stream

Quickstart Guide to Using the Media Stream Plugin

The plugin and complete documentation are available for download here in this PhoneGap Repo.

To show a live video stream add this code to your application’s JavaScript:

navigator.mediaDevices.getUserMedia({
'video': {
'facingMode': 'environment'
}
}).then(function(mediaStream) {
var mediaControl = document.querySelector('video');
mediaControl.srcObject = mediaStream;
mediaControl.src = URL.createObjectURL(mediaStream);
});

Stay Tuned!

This is the first version of the API… More improvements are coming down the pipeline! We will be continue to add more functionality as we incorporate feedback!

Issues

iOS is currently not able to attach the stream to the HTML <audio> or <video> elements. However, the stream that you receive from getUserMedia can be passed into the ImageCapture and MediaRecorder plugins to take pictures and record audio/video respectively.

Contact Us

Your feedback is graciously accepted and appreciated!
Please submit your pull requests and issues here.

--

--

Simon MacDonald
PhoneGap

Father, Software Engineer, Comic Enthusiast, Coffee Lover and Developer 🥑 for @AdobeIO