在 Android 中,当视频持续时间或 date_modified 属性可通过内容提供商获得时

发布于 2024-09-13 08:47:59 字数 256 浏览 2 评论 0原文

我在访问视频和图像的 DURATION 和 DATE_MODIFIED 等属性时遇到一些问题。我的应用程序访问这两种类型的数据的这些属性,但如果我拍照或拍摄视频,相关属性不会立即通过内容提供商提供,例如,对于该特定视频的持续时间,它返回 0。

如果我重新启动手机,则该属性的属性新拍摄的视频或拍摄的照片可供使用。

使这些属性可用的另一种方法是通过 USB 电缆将手机插入或拔出到计算机。一旦完成,属性就可用了。

对于为什么会发生这种情况有什么评论吗?

I'm having some trouble accessing attributes like DURATION and DATE_MODIFIED of video and image. My app access these attributes for both type of data but if I take a picture or shoot a video the related attributes are not immediately available through content provider e.g. for DURATION for that specific video it returns 0.

If I restart the phone the attribute for the newly shoot video or picture taken becomes available.

The other way to make the attributes available is to plug in and out your phone to a computer through usb cable. Once that is done the attributes are available.

Any comments on why this is happening ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆 2024-09-20 08:47:59

只是为了拯救某人我所经历的痛苦。需要的是 SDCARD 的媒体扫描,以使这些属性可以通过内容提供程序使用,并且 android 在安装媒体时执行此操作:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment) .getExternalStorageDirectory().toString())));

Just to save someone the misery I had to go through. What is required is a media scan of the SDCARD to make these properties available through the content provider and android does this when the media is mounted:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory().toString())));

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文