Android MediaStore 插入视频 [英] Android MediaStore insertVideo

查看:56
本文介绍了Android MediaStore 插入视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此我们的应用可以选择拍摄照片或视频.如果用户拍照,我们可以使用 MediaStore.Images.Media.insertImage 函数将新图像(通过文件路径)添加到手机图库并生成 content://样式 URI.鉴于我们只有它的文件路径,对于捕获的视频是否有类似的过程?

So our app has the option to take either a picture or a video. If the user takes a picture, we can use the MediaStore.Images.Media.insertImage function to add the new image (via a filepath) to the phone's gallery and generate a content:// style URI. Is there a similar process for a captured video, given that we only have it's filepath?

推荐答案

这是一个简单的基于单个文件的解决方案":

Here is an easy 'single file based solution':

每当您添加文件时,使用

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(imageAdded)));

主要优势:适用于 MediaStore 支持的任何 mime 类型

Main advantage: work with any mime type supported by MediaStore

每当您删除一个文件时,使用

Whenever you delete a file, let MediaStore Content Provider knows about it using

getContentResolver().delete(uri, null, null)

这篇关于Android MediaStore 插入视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆