android视频捕获无法正常工作
视频正在注册到画廊。但是当我把它保存在我指定的文件夹(照片文件夹)中时,它就不起作用了。这是什么原因?这是我的代码:android视频捕获无法正常工作,android,Android,视频正在注册到画廊。但是当我把它保存在我指定的文件夹(照片文件夹)中时,它就不起作用了。这是什么原因?这是我的代码: private void galleryAddVideo() { String timeStamp = new SimpleDateFormat("yyyyMMdd_HH:mm:ss").format(new Date()); String imageFileName = "VIDEO_" + timeStamp + &q
private void galleryAddVideo() {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HH:mm:ss").format(new Date());
String imageFileName = "VIDEO_" + timeStamp + "_";
File storageDir = new File(getExternalStorageDirectory().getAbsolutePath(), "Photo Klasör");
try {
imaasadge = File.createTempFile(imageFileName, ".mp4", storageDir);
} catch (IOException e) {
e.printStackTrace();
}
currentVideoPath = imaasadge.getAbsolutePath();
ContentValues values = new ContentValues(2);
values.put(MediaStore.Video.Media.MIME_TYPE, "video/*");
Uri uri = getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);
//MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values
try {
InputStream is = new FileInputStream(currentVideoPath);
OutputStream os = getContentResolver().openOutputStream(uri);
byte[] buffer = new byte[2048]; // tweaking this number may increase performance
int len;
while ((len = is.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
os.flush();
is.close();
os.close();
listem.clear();
Islemler();
} catch (Exception e) {
Log.e("TAasG", "exception while writing video: ", e);
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri));
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {
galleryAddVideo();
Log.d("fvdsfbd", "dsvbd");
}
}
我将视频保存在“照片文件夹”中,但视频在那里不起作用。我解决了我的问题。