Sunil
Sunil

Reputation: 929

Live video streaming with phonegap

I am trying to build a video chat application by using phonegap with HTML5 and JS. I tried some code with web RTC, but it works well only on desktop browser. When i built it from phonegap build, application fails to open camera. I tried with following code to stream a video from device cam, but it's not working. Any help will be appreciated.

navigator.webkitGetUserMedia(
        {
          //audio: true,
          video: true
        },

        function (stream) {
          localStream = stream;

          localVideo.src = window.URL.createObjectURL(stream);

          if (successCb) {
            successCb(stream);
          }
        },

        function (err) {
          logError('failed to access local camera');
          logError(err.message);
        }
      );

Upvotes: 1

Views: 3322

Answers (1)

Brad L.
Brad L.

Reputation: 1029

With your specific question above, you should probably put the Audio flag back in and make sure your app has permissions to use the camera by setting the permissions in the config.xml. What device are you trying it on will also make a big difference. See below for more info.

WebRTC support is still very spotty and buggy. I have several apps that use it. my recommendation for Android is to use the Crosswalk plugin which will give you as standard WebRTC experience as possible on Android.

I would also recommend using the peer.js wrapper as well to simplify things quite a bit no matter the platform.

On iOS there are no really great options that are stable, use the standard webRTC API, or not tied to a proprietary service.

The iosrtc plugin here exposes the WebRTC api but is buggy: https://github.com/eface2face/cordova-plugin-iosrtc

Other people have had success with the phonertc plugin here, but it does not expose the standard RTC api: https://github.com/alongubkin/phonertc/wiki

Upvotes: 1

Related Questions