-1

In my app my actual requirement is record video file and share to another through mail.. But present now i am able to record video file and share that file throgh mail friends or someone... my shared file is played sometimes on real device and some other times not plaing on real device. this happens because of reducing the file size on downloading the file . may be improper encoding of audio and video or output format of file or send to mail attachments problem...

where is the problem? please help me....

when record start my code is:

mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setOutputFile("/sdcard/myvideo.3gp");
mediaRecorder.setMaxDuration(60000); // Set max duration 60 sec.

and send file to mail code is:

fileshare = new File("/sdcard/myvideo.3gp");
File filelocation = fileshare ;
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("video/3gp");
sharingIntent.putExtra(Intent.EXTRA_EMAIL, "xxxxxxxxx@gmail.com" );
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+filelocation.getAbsolutePath()));
startActivity(Intent.createChooser(sharingIntent, "Send email"));
Little Boy
  • 11
  • 1
  • where is the problem in my code? why -ve marks?? – Little Boy Nov 10 '12 at 06:42
  • You can edit your question to include more details. From where you are trying to play the file? What do you meant by sometimes the file size is changed? After adding attachment does the size change? Not sure about the negative ratings, may be someone didn't like your id :-) , I upvoted one – Durairaj Packirisamy Nov 10 '12 at 07:59
  • i edited my question plz see it once and there is any idea suggest me.. and thanks for explanation – Little Boy Nov 10 '12 at 09:04

1 Answers1

1

Can't know for sure how you're doing it in your app, but you need to wait until MediaRecorder has finished writing the file before you do something else with it. You can do that by checking whether byte 4 of the file is >0 in an AsyncTask, or you could put in some kind of delay, although that would be less reliable.

Mike_SD
  • 123
  • 5
  • my file size is always >0 bytes some times i got less size than actual size at that time not playing and some times its playing correctly with actual size file.. – Little Boy Nov 12 '12 at 04:19