How to use camera with default controls/buttons?

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

Hi all, I am trying to record a video using the Ti.Media.showCamera but I can't find a control for this when the camera shows up so I want to ask is there a way to record video with default iOS camera controls without custom overlay/buttons or I've to must provide custom overlay or controls? I am on ios 5 and titanium 2.1.0 Thanks in advance.

— asked 9 months ago by Muhammad Qasim Khan
3 Comments
  • show some code... We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code! We need code!

    — commented 9 months ago by Aaron Saunders

  • I thought its a straight forward simple question so no code would be needed however if you need that much then here its:-

    btn_tkphoto.addEventListener('click',function(event)
        {
            if(Ti.Media.isCameraSupported)
                Ti.Media.showCamera({success:cam_success,
                                        cancel:cam_cancel,
                                        error:cam_error,
                                        saveToPhotoGallery:true, 
                                        allowEditing:true,
                                        videoMaximumDuration:20000})
            else
                alert('Sorry! Camera Not Supported.')
        })
    var cam_success=function(e)
        {
     
                if(e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
                    pic=e.media;
                else if(e.mediaType == Ti.Media.MEDIA_TYPE_VIDEO)
                    video=e.media;
        };
    var cam_cancel=function()
            {
                alert('you canceled');
            };
    var cam_error=function(error)
            {
                alert('there was an error');
            };
    It can only take photos from camera but couldn't record video.

    — commented 9 months ago by Muhammad Qasim Khan

  • if the answer worked, you should mark it as the best answer

    — commented 9 months ago by Aaron Saunders

1 Answer

It works after adding - showControls and mediaTypes to your options list for showCamera. I added what should be default as per the documentation, so I am not really sure why isnt working with the code you have. Anyways, here is the working code.

btn_tkphoto.addEventListener('click',function(event)
    {
        if(Ti.Media.isCameraSupported)
            Ti.Media.showCamera({success:cam_success,
                                    cancel:cam_cancel,
                                    error:cam_error,
                                    saveToPhotoGallery:true, 
                                    allowEditing:true,
                                    mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO],
                                    showControls:true,
                                    videoMaximumDuration:20000})
        else
            alert('Sorry! Camera Not Supported.')
   });
 
var cam_success=function(e)
    {
 
            if(e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
                pic=e.media;
            else if(e.mediaType == Ti.Media.MEDIA_TYPE_VIDEO)
                video=e.media;
    };
var cam_cancel=function()
        {
            alert('you canceled');
        };
var cam_error=function(error)
        {
            alert('there was an error');
        };

Your Answer

Think you can help? Login to answer this question!