Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24214] Android: VideoMaximumDuration and VideoQuality are not working using Android 6

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2018-07-27T17:38:53.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
Reporter Ricardo Ramirez
AssigneeLokesh Choudhary
Created2016-12-12T22:40:28.000+0000
Updated2018-07-27T17:38:53.000+0000

Description

h2 Issue Description Trying to increase the limit size and quality of videos it's capturing is not working using:
function showCamera_Android(e) {
    Ti.Media.showCamera({
		success : onMediaSuccess,
		cancel 	: onMediaCancel,
		error 	: onMediaError,	
		saveToPhotoGallery 	: true,
		allowEditing 	: true,
		videoMaximumDuration : 5000,
		videoQuality	: Ti.Media.QUALITY_MEDIUM,
		mediaTypes 	: [Ti.Media.MEDIA_TYPE_VIDEO]
});
works on iOS and Android 5, but not using 6. Creating Intents is also not working:
function showCamera_Android()
{
	var intent = Titanium.Android.createIntent({ action: 'android.media.action.VIDEO_CAPTURE' });


	/*
	 * THESE INTENTS ARE NOT WORKING
	 * 
	 */

	intent.putExtra("android.provider.MediaStore.EXTRA_VIDEO_QUALITY",0);
    intent.putExtra("android.provider.MediaStore.EXTRA_DURATION_LIMIT",3);

	/*
	 * THESE INTENTS ARE NOT WORKING EITHER
	 * 
	 */
	// intent.putExtra("android.intent.extra.durationLimit", 3);
	// intent.putExtra("android.intent.extra.videoQuality", 0); 

    $.winMain.getActivity().startActivityForResult(intent, function(e) {
        
        
        if (e.error) 
        {
        } 
        else 
        {
        	if (e.resultCode === Titanium.Android.RESULT_OK) {
        		
	        	var videoUri 	= e.intent.data;
	            var source 		= Ti.Filesystem.getFile(videoUri);
			    var movieFile 	= Ti.Filesystem.getFile('appdata://sample.3gp');
			
				if (movieFile.exists()) 
					movieFile.deleteFile();
				
				movieFile 	= Ti.Filesystem.getFile('appdata://sample.3gp');
				
			    source.copy(movieFile.nativePath);
			    videoBlob = movieFile;
				
				var buffer = Ti.createBuffer({ value: "test"});
				imgBlob = buffer.toBlob();
				
				$.vidPlayer.url = videoUri;
	        	$.vidPlayer.play();	
	        	
	        }
        }
        
    });
}

Steps to reproduce

Download the attached zip https://drive.google.com/open?id=0BwTWo-c2a0b9UlJVdTRvQkI3VUU

Run for android6

Record video

Comments

  1. Frankie Merzadyan 2016-12-13

    Seems like a permission error. For 23+ API (Android 6), you need to explicitly ask for permissions for use of features. So for video recording it would be: In AndroidManifest.xml
       <uses-permission android:name="android.permission.CAMERA"/>
       <uses-permission android:name="android.permission.RECORD_AUDIO"/>
       <uses-feature android:name="android.hardware.camera2" android:required="true"/>
       
    Please use that workaround for now while I fix this. :)
  2. Frankie Merzadyan 2017-01-09

    You need to add permissions in tiapp.xml #android #manifest tag. When the android app is generated, those will be inserted into #manifest tag in AndroidManifest.xml. No permission will be granted on Android if it's not in the AndroidManifest.xml. After that the user needs to enable simply permissions. [~rramirez].
  3. Rob Trueman 2017-02-02

    The problem isn't with access to the camera, but in the maximum video duration and quality. My initial app permissions include: I also added: after finding this ticket, but it didn't help. Are you able to limit the video length?
  4. Frankie Merzadyan 2017-03-15

    [~rtrueman], you can limit video length by changing the videoMaximumDuration value which is uses ms as a measurement unit. I still could not reproduce error using Samsung Galaxy S6 and latest Titanium SDK version (master). Here is the app code:
       var win;
       function fireCamera() {
       	if (Ti.Platform.osname === 'android' || Ti.Platform.osname == "iphone" || Ti.Platform.osname == 'ipad') {
       		win.removeEventListener('focus', fireCamera);
       	}
       	Titanium.Media.showCamera({
       
       		success: function (event) {
       			var cropRect = event.cropRect;
       			var image = event.media;
       
       			if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
       				var imageView = Ti.UI.createImageView({
       					width: win.width,
       					height: win.height,
       					image: event.media
       				});
       				win.add(imageView);
       			}
       		},
       		cancel: function () {
       
       		},
       		error: function (error) {
       			if (error.code == Titanium.Media.NO_CAMERA) {
       				console.log("", "device has no camera", error)
       			}
       			else {
       				console.log(error.code, "unexpected error", error);
       			}
       		},
       		saveToPhotoGallery: true,
       		allowEditing: true,
       		videoMaximumDuration: 2000,
       		videoQuality: Ti.Media.QUALITY_MEDIUM,
       		mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO]
       	});
       }
       win = Titanium.UI.createWindow({
       	title: "classic_app"
       });
       win.open();
       if (Ti.Platform.osname === 'android' || Ti.Platform.osname == "iphone" || Ti.Platform.osname == 'ipad') {
       	win.addEventListener('focus', fireCamera);
       } else {
       	fireCamera();
       }
       
  5. Lokesh Choudhary 2017-05-23

    Tried to reproduce the issue using both the attached app & the code by [~fmerzadyan] & what I see is the video does not auto stop recording after the VideoMaximumDuration is elapsed or restricts the recording to the given duration. Also, the for me the VideoQuality always comes out to be the highest. Studio Ver: 4.9.0.201705180402 SDK Ver: 6.0.4.GA OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.2 Appc NPM: 4.2.9 Appc CLI: 6.2.1 Ti CLI Ver: 5.0.13 Alloy Ver: 1.9.11 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: ⇨ oneplus A0001 --- Android 6.0.1

JSON Source