Video Gallery

You must Login before you can answer or comment on any questions.

Hi , i would like to know if it is possible to get a video gallery for my application because it seems that the only gallery possible to implement is the photogallery

What can i do to display videos and then choose a video like the photogallery?

6 Answers

If you want to just enable the choosing of videos from the built-in gallery picker, add mediaTypes: [Titanium.Media.MEDIA_TYPE_VIDEO] when you call Ti.Media.openPhotoGallery - then it will only show the videos in the gallery.

— answered 3 years ago by Kosso .
answer permalink
1 Comment
  • I can not get tHis to work. Can you post an complete example code to open photogallery with video.

    Would be great, thanks

    — commented 3 years ago by Jimmy Escherich

It would like to upload videos after choosing or capturing. It is possible 2 months later? Please can i have a clear answer to know if i have to give up Titanium or not because it's very urgent.

Thanks

It would like to upload videos after choosing or capturing. It is possible 2 months later? Please can i have a clear answer to know if i have to give up Titanium or not because it's very urgent.

Thanks

Hey Jimmy,

did you manage to do it on Android? The solution Kosso suggested only works on iOS.

My best regards!

— answered 1 year ago by Douglas Alves
answer permalink
5 Comments
  • I found a solution for Android, but I am still struggling to get it working on Iphone.

    if(Ti.Platform.osname == 'android')
                {
                    var intent = Titanium.Android.createIntent({ 
                        action: Ti.Android.ACTION_PICK,
                        type: "video/*"
                    }); //android.media.action.VIDEO_CAPTURE
     
                    intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
     
                    window.activity.startActivityForResult(intent, function(e)
                    {
                        if (e.error) 
                        {
                            Ti.UI.createNotification({
                                duration: Ti.UI.NOTIFICATION_DURATION_SHORT,
                                message: 'Error: ' + e.error
                            }).show();
                        } 
                        else 
                        {
                            if (e.resultCode === Titanium.Android.RESULT_OK) 
                            {
                            videoFile = e.intent.data;
     
                                var source = Ti.Filesystem.getFile(videoFile);
                                movieFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'mymovie.3gp');
                                source.copy(movieFile.nativePath);
     
                                videoFile = movieFile.nativePath;
     
     
                                    r.onload = function() {
                                            var callback = JSON.parse(this.responseText);
     
                                         if (callback.status == 'ok'){}
                                    };
     
                                    xhr.onerror = function(e){};
     
                                    xhr.onsendstream = function(e){
                                    Ti.API.info('ControladorTelas - ON SEND STREAM - PROGRESS: ' + e.progress);
                            };
     
                                    if(movieFile.exists())
                                    {
                                            xhr.send({
                                                video: source,
                                            });
                                            movieFile.deleteFile();
                                    }
                                    else
                            {}
                                } 
                                else 
                            {
                                    Ti.UI.createNotification({
                                            duration: Ti.UI.NOTIFICATION_DURATION_SHORT,
                                            message: 'Canceled!'
                                        }).show();
     
                                }
                         }
                   });
                }

    — commented 12 months ago by Douglas Alves

  • Dude thank you so much =).

    — commented 8 months ago by Mauricio Stand

  • MaurĂ­cio,

    I found the solution for the Iphone as well! :)

    Ti.Media.openPhotoGallery({
        allowEditing: true,
        mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],
        success:function(event) {                   
            xhr_video = Ti.Network.createHTTPClient({enableKeepAlive:false});
            xhr_video.onload = function(e){
                Ti.API.info("OK: " + this.responseText);
     
                Ti.UI.createAlertDialog({
                    title: 'Success',
                    message: 'Video uploaded',
                    OK: 'OK'
                }).show();
            };
     
            xhr_video.timeout = config.TimeOut();
     
            xhr_video.onerror = function(e){ 
                Ti.API.info('ERROR => ' + e.error);
            };
     
            xhr_video.onsendstream = function(e){
                Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
            };
     
            xhr_video.open('POST', 'http://myServer/video_upload');
            xhr_video.send({
                video: event.media  //video,
            });
        }
    });

    — commented 8 months ago by Douglas Alves

  • Show 2 more comments

if (Ti.Platform.osname == 'android') {
                var intent = Titanium.Android.createIntent({
                    action : Ti.Android.ACTION_PICK,
                    type : "video/*"
                });
                //android.media.action.VIDEO_CAPTURE
                intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
                self.activity.startActivityForResult(intent, function(e) {
                    if (e.error) {
                        Ti.UI.createNotification({
                            duration : Ti.UI.NOTIFICATION_DURATION_SHORT,
                            message : 'Error: ' + e.error
                        }).show();
                    } else {
                        if (e.resultCode === Titanium.Android.RESULT_OK) {
                            videoFile = e.intent.data;
                            var source = Ti.Filesystem.getFile(videoFile);
                            movieFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'mymovie.3gp');
                            source.copy(movieFile.nativePath);
                            videoFile = movieFile.nativePath;
                            scene_picker(source);
                        } else {
                            Ti.UI.createNotification({
                                duration : Ti.UI.NOTIFICATION_DURATION_SHORT,
                                message : 'Canceled!'
                            }).show();
                        }
                    }
                });
            }

— answered 6 months ago by Sedat Bilen
answer permalink
1 Comment
  • there is a function of mine in it which you can simply remove which is:

    scene_picker(source);

    — commented 6 months ago by Sedat Bilen

I am also still not able to view the video in the photogallary. Is there any solution. The code i have used is as below.

Titanium.Media.openPhotoGallery({ success : function(event) { Ti.API.debug('Our type was: ' + event.mediaType); if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO || Ti.Media.MEDIA_TYPE_VIDEO) { UploadPhotoToServer(event.media); } }, cancel : function() { }, error : function(err) { Ti.API.error(err); }, mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO, Ti.Media.MEDIA_TYPE_VIDEO] });

Your Answer

Think you can help? Login to answer this question!