Appcelerator Titanium: how to record video?

2019-05-22 15:17发布

问题:

How to record video in Appcelerator Titanium and store in a specific location ?

I am using an Android 2.3.6 device.

This gist: https://gist.github.com/832488 does not seem to work as suggested / expected. It starts the video capture intent

var intent = Titanium.Android.createIntent({ action: 'android.media.action.VIDEO_CAPTURE' });

as an activityForResult but the callback in

Titanium.Android.currentActivity.startActivityForResult(intent, function(e) { ... });

is never called, none of notifications in code appear and the video is stored in some default location.

The KitchenSink app does not have any video example[for Android], only a camera example code. It does have a record_video module for android video capture but it only manages to capture a picture. The line

mediaTypes: Titanium.Media.MEDIA_TYPE_VIDEO,

does not seem to be working

Any help is appreciated. Thanks.

回答1:

It turns out that its all a 'context' play.

Found the reason at http://developer.appcelerator.com/question/137709/startactivityforresult-and-callback-function-problem#244265

  • The problem really is the use of heavyweight windows in Android by the SDK which means a new Javascript context.
  • A heavyweight window is always created when you open a new window from inside a TabGroup.

So, the gist at: https://gist.github.com/832488 works, given that the camera is not launched from within (inside) of a tabgroup.