Can't view Video in Android

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

In my code (for Android), I'm using the following.

var intent = Titanium.Android.createIntent({ action: 'android.media.action.VIDEO_CAPTURE' });
    Titanium.Android.currentActivity.startActivityForResult(intent, function(e) {
 
            if (e.resultCode === Titanium.Android.RESULT_OK) {
                videoFile = e.intent.data;
               var scramble=new Date();
               var scramble=scramble.getTime();
               scramble=scramble.toString()+'.mov';
               var source = Ti.Filesystem.getFile(videoFile);
                movieFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, scramble);
                            source.copy(movieFile.nativePath);
 
                            videoFile = movieFile.nativePath;
 
.
.
.
and other code not relevant.

The problem is that I cant play this video, even if its taken from an Android device. I've changed the exetension to 3gp to see if that would work, but it doesnt. I can view the videos fine on Android.

Seems silly that I can't even view the video I recorded on the device. Does anyone else have working code to record and view video?

My video player is

if(osname=='android')
        {
        var holder=Titanium.Media.createVideoPlayer({
        top:'40dp',
        bottom:'50dp',
        url:win.data, //my video, yes it is there
        autoplay:true,
        movieControlMode : Titanium.Media.VIDEO_CONTROL_DEFAULT,
        scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
        });
 
        }

1 Answer

Hi Josh,

Try to find Titanium.Filesystem.applicationDataDirectory and movieFile.nativePath path in your application and compare it.

I am also facing this problem, I think normally Titanium application stored in to phone memory and data directory reference to the phone memory by default. I got different path all time when I am trying to store video to data directory. and also found a directory in memory card.

I still have no luck. so I try to store at specific location on the memory, try to create a folder in phone memory and store all video in it. It works for me.

If you find any solution then please share it.

Make sure the file type you selected for storage it supported by android player.

— answered 2 years ago by Gaurang Chhatbar
answer permalink
1 Comment
  • Well, I'm not trying to store it, I'm trying to stream it. That code I posted was just the capturing part, I send it later to my server (and I can verify its there).

    In another section of my app, I just pull in the http path to the video, and thats where it just sits.

    — commented 2 years ago by Josh Lewis

Your Answer

Think you can help? Login to answer this question!