Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24707] Android: Add video support to Ti.Media.openPhotoGallery()

GitHub Issuen/a
TypeImprovement
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-05-10T18:44:05.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sRelease 7.3.0
ComponentsAndroid
Labelsandroid, gallery, video
ReporterFazlul Haque
AssigneeJoshua Quick
Created2017-05-18T15:51:38.000+0000
Updated2018-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?

Comments

  1. Sharif AbuDarda 2017-05-18

    This is a valid query for Android. Moving to Engineering.
  2. Frankie Merzadyan 2017-07-17

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9223
  3. Joshua Quick 2017-12-07

    Frankie's PR has been updated. Pending final review.
  4. Hans Knöchel 2018-02-09

    [~jquick] Just to be sure: AC-5581 is something else right?
  5. Joshua Quick 2018-02-09

    [~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?
  6. Gary Mathews 2018-02-14

    Bumping from 7.1.0, we need to cleanup this PR and fix conflicts.
  7. Lokesh Choudhary 2018-05-09

    FR Passed. Waiting merge to get enabled.
  8. Lokesh Choudhary 2018-05-10

    PR Merged.
  9. Lokesh Choudhary 2018-07-02

    Verified the fix in SDK7.3.0.v20180628132121. Closing.

JSON Source