[TIMOB-24707] Android: Add video support to Ti.Media.openPhotoGallery()
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-05-10T18:44:05.000+0000 |
Affected Version/s | Release 6.1.0 |
Fix Version/s | Release 7.3.0 |
Components | Android |
Labels | android, gallery, video |
Reporter | Fazlul Haque |
Assignee | Joshua Quick |
Created | 2017-05-18T15:51:38.000+0000 |
Updated | 2018-07-02T22:00:54.000+0000 |
Description
Hello,
We have tried to open the videos from Android gallery but its not opening.
*Testing Environment:*
Titanium SDK: 6.0.4.GA
Appcelerator Command-Line Interface, version 6.2.0
Android device: Samsung Galaxy Grand Prime(5.1.1)
*Test Code:*
var storagePermission = "android.permission.READ_EXTERNAL_STORAGE";
var hasStoragePermission = Ti.Android.hasPermission(storagePermission);
var permissionsToRequest = [];
var win = Ti.UI.createWindow({
title : 'mywin',
backgroundColor : '#fff',
width : Ti.UI.FILL,
height : Ti.UI.FILL
});
win.open();
if (!hasStoragePermission) {
permissionsToRequest.push(storagePermission);
}
if (permissionsToRequest.length > 0) {
Ti.Android.requestPermissions(permissionsToRequest, function(e) {
if (e.success) {
Ti.API.info("SUCCESS");
} else {
Ti.API.info("ERROR: " + e.error);
}
});
}
var btn1 = Ti.UI.createButton({
title : 'Click',
top : 60
});
win.add(btn1);
btn1.addEventListener('click', function() {
Ti.Media.openPhotoGallery({
mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],
success: function (e) {
Ti.API.info("Success");
},
cancel: function () {
},
error: function (e) {
Ti.API.error(JSON.stringify(e));
}
});
});
Tiapp.xml
<manifest>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application android:hardwareAccelerated="true" android:largeHeap="true"/>
</manifest>
*Test Result:*
Just Opening the Photos from gallery but videos are not Opening.
*Expected Result:*
Open the videos also from Android App Gallery.
Photo gallery API shows videos too for iOS. Am I missing something or this is not available for Android? If not available for Android, Can we consider it for improvement?
This is a valid query for Android. Moving to Engineering.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/9223
Frankie's PR has been updated. Pending final review.
[~jquick] Just to be sure: AC-5581 is something else right?
[~hknoechel], my updated PR for this case fixes the blob/file handling for videos too, allowing it to be played via a VideoPlayer. So, it should theoretically upload the video file now **BUT** our HTTPClient API is currently coded to write a blob to file before uploading it, which we don't want to do since videos tend to be huge. https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L904 We might not have enough storage space and it'll cause a significant delay before starting the upload (must wait until it finishes writing to storage). It should probably be optimized to stream the bytes from blob instead. *Edit:* Actually, it sounds like [AC-5581] is a really a WebView issue where the JavaScript is unable to show a video selection dialog?
Bumping from 7.1.0, we need to cleanup this PR and fix conflicts.
FR Passed. Waiting merge to get enabled.
PR Merged.
Verified the fix in SDK7.3.0.v20180628132121. Closing.