December 22nd, 2011, 05:13 AM
|
#1 (permalink)
|
|
New Member
Join Date: Jul 2010
Location: London
Posts: 3
Device(s): HTC Desire, LG
Thanks: 0
Thanked 0 Times in 0 Posts
|
Cannot play video recorded on SD card from Android application on PC?
I have managed to take a video in my application and save it to a folder on my SD card, but when I check the SD card and play it on my PC it doesn't seem to play, it's just a black screen! The video is also 0KB. I'm using API 8 and above and I've tried saving it as .mpeg, .3gp and .mp4. My video activity is the same as my camera activity (which works perfectly) except I've changed all the camera type arguments to video arguments.
Code:
public class VideoActivity extends Activity
{
final int VIDEO_ACTIVITY = 1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent h = getIntent();
String filename = h.getStringExtra("string") + ".mpeg";
String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + "/" + getString(R.string.app_name)+ "/";
File newdir = new File(dir);
try{
newdir.mkdirs();
}
catch(Exception e){}
String file = dir + filename;
File newfile = new File(file);
try {
newfile.delete();
newfile.createNewFile();
} catch (IOException e) {}
Uri outputFileUri = Uri.fromFile(newfile);
Intent videoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(videoIntent, VIDEO_ACTIVITY);
}
}
|
|
|