Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limitations of Video Capture in Phone Gap + Native Plugins

I am developing a mobile app targeting the iOS and Android platforms. The app will consist of:

  1. A relatively simple 'user login/signup and listing of database items' type of interface, powered by an already built webservice from and existing web application.

  2. A video capture and upload feature using native plugins.

I have done extensive research on PhoneGap for the last week, and have determined that even considering the well documented issues and limitations of PhoneGap, it is well suited for the 1st part of my app.

However, given the limitations of the PhoneGap Capture API ( org.apache.cordova.media-capture ), it is not appropriate for capturing video for upload, mostly due to the lack of control over video specs. (On most devices, video captures will be enormous HD files that are not suitable for upload, even on Wifi, and certainly not over 3g/4g.)

Given my resources and timeline, I've determined that building native apps in both Java and ObjC are impractical, at least for now. I have very little ObjC and Java experience, but I am fairly confident and eager to learn these languages if need be.

That said, I am considering 2 options:

  1. The first, and probably most rational, is that I pick the platform with the greater market share of my existing user base (iOS), suck it up, and go native.

  2. The second, and perhaps lofty option, is that I develop a hybrid app in PhoneGap, targeting both platforms, and circumvent the limitations of my video capture ability by building native plugins for Java and ObjC using PhoneGap's plugin API, thus reducing development time on the rest of the app, and using native code only where it's needed.

The requirements of my video capture plugin would be as follows:

  1. Have complete control over the specs of the recorded video, most importantly resolution and bitrate. (Presumably with AVFoundation, and the like in Adroid SDK).

  2. Control the user interface of the video capture functionality.

Obviously, I am aware that these tasks are very possible on both platforms when developing in the native api's as is evident by existing apps in the market. (Vine, etc..).

My real question, is what are the limitations, and issues with extending native functionality via PhoneGap's Plugin API? There are almost no examples of work done in PhoneGap with this level of native implementation of video capture. The one example I've found is this plugin, VideoCapturePlus, which although I haven't been able to get to work, seems promising.

I am especially interested to find out if anyone out there has successfully implemented native plugins in PhoneGap with this level of complexity, or if it is a rabbit hole I will wish I hadn't gone down.

like image 991
Oliver Holmberg Avatar asked Feb 26 '14 16:02

Oliver Holmberg


1 Answers

I have essentially gotten to the bottom of this question, that I am sure others are and will face. I will address the topic in 3 parts:

Can I do [something] in PhoneGap (as opposed to in native iOS or Android SDK)?

This is a question I'd imagine many developers considering the PhoneGap framework find themselves asking, as did I. The short answer is YES, YOU PROBABLY CAN.

How do I do [something] in PhoneGap?

Plugins! Here's the rub: Cordova (PhoneGap) in all it's brilliance is extremely limited in the way it accesses native hardware features, especially when you get into video/photo/audio capture.

This is where plugins come in. There are thousands of PhoneGap plugins at this point. Many are as simple as 4 lines of Java and Objective C to get over some simple thing that PhoneGap just won't do. Others are large projects with lifecycles of their own.

In my case, it became very clear very early on that I was not going to be able to build my app with the video capture functions that existed in PhoneGap. That said, I went shopping for plugins. By the end of my project it had taken 2 plugins that extended video functionality and four more to do other small various things I needed. In a few cases, the plugins I found did not have everything I needed, and I wound up contributing bits of code. If the projects are active on GitHub, I highly recommend this.

In the end, there were things I wanted to do that I could not find plugins for. I still have plans to build some of my own, but am not there yet. Bottom line: Outside of gaming and other 3d rendering applications, you'll be hard pressed to find something that can't be achieved with a PhoneGap plugin.

For those interested specifically in video capture, these are the 2 plugins that got me over the hump in my project:

VideoCapturePlus

Video Screenshot

Should I build my app that does [something] in PhoneGap?

Of course, this question is up to each developer, and what the goals of the app are. In my case, a simple app that among other things captures and uploads photos and short videos was quite possible. There are certainly cases in which the parameters and goals of the app make it such that native development is the best option.

That said, for most solo devs or small teams with limited resources and little or no Java or ObjC experience, the answer to the question, "Should I consider PhoneGap?", would be [in my best Jim Halpert voice], "Absolutely you should". As an added bonus, I will say this: In my case, the HTML5 layouts, and much of the front end JS that were used for both the Android and iOS versions of my app are largely reusable for the mobile web version of my app. Being able to maintain a single codebase for those three things offers efficiency that even larger resourced organizations shouldn't overlook.

like image 87
Oliver Holmberg Avatar answered Nov 15 '22 15:11

Oliver Holmberg