如何从 ListView 中的特定文件夹中获取带有缩略图和文本的视频,例如 youtube

发布于 2024-11-16 00:51:16 字数 855 浏览 8 评论 0 原文

我正在尝试在特定文件夹的列表视图中显示视频缩略图和文本。 我正在获取缩略图,但是当我向视频添加文本并使用 ContentValues 进行更新时, 我得到所有视频上的文字。我将视频保存在自定义文件夹“/sdcard/myfolder/”中。

这就是我保存捕获的视频的方式(自定义摄像机):

ContentResolver contentResolver = getContentResolver();
Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;// how to specify folder
Uri newUri = contentResolver.insert(base, values);

我从图库中获取所有视频,如何指定文件夹。

这就是我尝试向列表视图中的每个视频添加文本的方法:

ContentValues values = new ContentValues(1);     
values.put(MediaStore.Video.Media.DESCRIPTION, edtext.getText().toString());
//values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
ContentResolver contentResolver = getContentResolver();
Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
contentResolver.update(base, values,null,null);

这向所有视频添加相同的文本......有任何帮助吗?

I'm trying to show video thumbnail and text in a Listview from specific folder.
I am getting the thumbnails,but when i add text to a video and update using ContentValues,
I get the text on all videos. I saved the videos in a custom folder "/sdcard/myfolder/".

this is how i save the video captured(custom camera recorder):

ContentResolver contentResolver = getContentResolver();
Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;// how to specify folder
Uri newUri = contentResolver.insert(base, values);

I'm getting all videos from gallery, how to specify a folder.

This is how i try adding text to each video in Listview:

ContentValues values = new ContentValues(1);     
values.put(MediaStore.Video.Media.DESCRIPTION, edtext.getText().toString());
//values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
ContentResolver contentResolver = getContentResolver();
Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
contentResolver.update(base, values,null,null);

This adds same text to all videos....any help?

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

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

发布评论

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

评论(1

夜唯美灬不弃 2024-11-23 00:51:16

这段代码:

ContentValues values = new ContentValues(1);     
values.put(MediaStore.Video.Media.DESCRIPTION, edtext.getText().toString());
//values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
ContentResolver contentResolver = getContentResolver();
Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
contentResolver.update(base, values,null,null);

似乎正在尝试在数据库中插入和更新值...如果您想从数据库中获取值并将它们显示在 listView 中,我建议您查看此 教程

如果您确实只是想从文件夹中提取项目并将其显示在列表中,我建议使用自定义ListViewAdapter教程此处。在他使用 Twitter Api 的地方,您将用提到的目录的 IO 内容替换该代码......

This code:

ContentValues values = new ContentValues(1);     
values.put(MediaStore.Video.Media.DESCRIPTION, edtext.getText().toString());
//values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
ContentResolver contentResolver = getContentResolver();
Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
contentResolver.update(base, values,null,null);

appears to be trying to insert and update values in a database... If you want to take values from a database and display them in a listView I would recommend looking at this tutorial

If you are truly just wanting to pull items from a folder and display them in a list I would recommend using a Custom ListViewAdapter tutorial here. Where he is using Twitter Api you will be replacing that code with IO stuff for the directory mentioned...

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