Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old 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
Default 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);
    }
}

litterbug_kid is offline  
Reply With Quote
Sponsors
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:58 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo