Android Intent MediaStore.ACTION_VIDEO_CAPTURE with EXTRA_OUTPUT failed to play, return

I am trying to create an application that records video and saves it on an SD card, and when it starts up again, it overwrites the previous video.

The problem is that when I specify Intent extra EXTRA_OUTPUT, the camera is recording video to a location but it crashes when it replayes and plays clicks.

The code I use is as follows:

_path = Environment.getExternalStorageDirectory() + "/examplevideo.3gp"; File file = new File(_path); Uri outputFileUri = Uri.fromFile(file); Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE ); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, 0); 

When I stop recording, the logarithm says

 VERBOSE/videocamera(6602): Setting current video filename: null 

which is strange and seems like a problem.

When I press the play button, I get an error message, but the application continues to work (the recorded video does not play)

 ERROR/videocamera(6602): Couldn't view video file:///mnt/sdcard/examplevideo.3gp ERROR/videocamera(6602): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/examplevideo.3gp } ERROR/videocamera(6602): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408) ERROR/videocamera(6602): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) ERROR/videocamera(6602): at android.app.Activity.startActivityForResult(Activity.java:2817) ERROR/videocamera(6602): at android.app.Activity.startActivity(Activity.java:2923) .. 

When I click again, the application completely crashes with an error:

 ERROR/AndroidRuntime(6602): FATAL EXCEPTION: main ERROR/AndroidRuntime(6602): java.lang.IllegalArgumentException: Unknown URL file:///mnt/sdcard/examplevideo.3gp ERROR/AndroidRuntime(6602): at android.content.ContentResolver.delete(ContentResolver.java:671) ERROR/AndroidRuntime(6602): at com.android.camera.VideoCamera.deleteCurrentVideo(VideoCamera.java:1010) ERROR/AndroidRuntime(6602): at com.android.camera.VideoCamera.discardCurrentVideoAndInitRecorder(VideoCamera.java:476) ERROR/AndroidRuntime(6602): at com.android.camera.VideoCamera.onClick(VideoCamera.java:420) ERROR/AndroidRuntime(6602): at android.view.View.performClick(View.java:2408) ... 

It’s strange that this video is saved in this place, and I can play it from my SD card, just so that the camera’s activity does not recognize it.

Some help or ideas would be much appreciated!

+4
source share
1 answer

It seems that you are trying to start the video player based on your error message (as opposed to playing video in VideoView widgets.

Try to indicate that your intent data is of a video type:

 Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse(yourVideoURI), "video/*"); startActivity(i); 

Note that yourVideoURI above will be that you will return from data.getData() to onActivityResult()

0
source

Source: https://habr.com/ru/post/1338072/


All Articles