I am designing an app with media functionality, one of which is video capturing. I am using a default call to the Camera instead of creating my own camera. The problem I am having is that after capturing a video it does not save into a video file I designated, but this problem, so far that I have tested, only happens on Samsung phones using the stock camera app. It works fine if I use the Google Camera on a Samsung phone or a phone from a different company. Is this a known bug for Samsung phones or am I just doing something wrong? If it is is there a workaround it?
Here is my videoHandler.
private void videoHandler() {
Intent intent = new Intent( MediaStore.ACTION_VIDEO_CAPTURE );
if ( intent.resolveActivity( getPackageManager() ) != null ) {
File videoFile = null;
try {
videoFile = createVideoFile();
} catch ( IOException e ) {
System.out.println( "Error creating file." );
}
if ( videoFile != null ) {
videoUri = Uri.fromFile( videoFile );
intent.putExtra( MediaStore.EXTRA_OUTPUT, videoUri );
intent.putExtra( MediaStore.EXTRA_VIDEO_QUALITY, 1 );
intent.putExtra( MediaStore.EXTRA_SIZE_LIMIT, 15000000L );
intent.putExtra( MediaStore.EXTRA_DURATION_LIMIT, 6 );
startActivityForResult( intent, VIDEO_REQUEST_CODE );
}
}
}
It calls createVideoFile, where I pre create a video file for a destination.
private File createVideoFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat( "yyyyMMdd_HHmmss" ).format( new Date() );
String imageFileName = "MP4_" + timeStamp + "_";
File storageDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES );
File video = File.createTempFile(
imageFileName, /* prefix */
".mp4", /* suffix */
storageDir /* directory */
);
this.videoUri = Uri.fromFile( video );
Intent mediaScanIntent = new Intent( Intent.ACTION_MEDIA_SCANNER_SCAN_FILE );
mediaScanIntent.setData( this.videoUri );
this.sendBroadcast( mediaScanIntent );
return video;
}
Here is the error I get when I try calling the videouri in my onActivityResult.
01-17 16:37:23.254 27162-28145/com.example.kevinem.blitz E/ImageLoader﹕ /storage/emulated/0/Pictures/MP4_20150117_163704_-918353230.mp4: open failed: ENOENT (No such file or directory)
java.io.FileNotFoundException: /storage/emulated/0/Pictures/MP4_20150117_163704_-918353230.mp4: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:409)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at java.io.FileInputStream.<init>(FileInputStream.java:105)
at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromFile(BaseImageDownloader.java:160)
at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)
at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:93)
at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:73)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:264)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:237)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:393)