首页 \ 问答 \ 如何从视频路径中显示视频缩略图?(how can I show a video thumbnail from a video path?)

如何从视频路径中显示视频缩略图?(how can I show a video thumbnail from a video path?)

我想通过存储上的视频路径在ImageView中显示视频缩略图。 是否有一个函数采用视频路径并返回缩略图的位图? 我通过以下代码获取视频路径:

public ArrayList<String> getAllMedia() {
  HashSet<String> videoItemHashSet = new HashSet<>();
  String[] projection = {MediaStore.Video.VideoColumns.DATA, MediaStore.Video.Media.DISPLAY_NAME};
  Cursor cursor = getContext().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
  try {
    cursor.moveToFirst();
    do {
      videoItemHashSet.add((cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA))));
    } while(cursor.moveToNext());
    cursor.close();
  } catch(Exception e) {
    e.printStackTrace();
  }
  ArrayList<String> downloadedList = new ArrayList<>(videoItemHashSet);
  return downloadedList;
}

I want to show a video thumbnail in an ImageView from a video path on storage. Is there a function that takes a video path and returns a bitmap of a thumbnail? I get the video path by this code:

public ArrayList<String> getAllMedia() {
  HashSet<String> videoItemHashSet = new HashSet<>();
  String[] projection = {MediaStore.Video.VideoColumns.DATA, MediaStore.Video.Media.DISPLAY_NAME};
  Cursor cursor = getContext().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
  try {
    cursor.moveToFirst();
    do {
      videoItemHashSet.add((cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA))));
    } while(cursor.moveToNext());
    cursor.close();
  } catch(Exception e) {
    e.printStackTrace();
  }
  ArrayList<String> downloadedList = new ArrayList<>(videoItemHashSet);
  return downloadedList;
}

原文:https://stackoverflow.com/questions/50073474
更新时间:2023-03-07 20:03

最满意答案

有几种选择:

您可以通过更改设置来使用SnapLinesSnapToGrid

工具 - >选项 - > Windows窗体设计器 - >常规 - >布局模式(和ShowGrid,SnapToGrid)

请注意,您需要关闭并重新打开设计器才能使更改生效。

或者,您可以通过选择要对齐的对齐并使用“布局”工具栏上的对齐功能来对齐控件。 要显示“布局”工具栏,请右键单击工具栏的空白区域(然后您应该看到一长串可用工具栏),并选中“布局”复选框。


There are a couple of options:

You can use either SnapLines or SnapToGrid by changing settings here:

Tools -> Options -> Windows Forms Designer -> General -> Layout Mode (and ShowGrid, SnapToGrid)

Note, you'll need to close and reopen the designer for the changes to take effect.

Or, you can align controls by selecting the ones you wish to align and using alignment functions on the Layout toolbar. To display the Layout toolbar, right-click on an empty area of your toolbar (you should then see a long list of available toolbars), and check the checkbox for "Layout".

相关问答

更多
  • 我因为工作的关系,最近也在找visual studio 2005的安装软件,不过总算找到了。因为我是用WEB迅雷下载软件的,所以在迅雷相关的搜索引擎里面找到的,我把网址告诉你,不过下载下来的软件是试用版的,不过你只要注册一下就可以了,具体方法如下: 下载地址: http://58.61.39.221/down?cid=EA459D0489DCCDBCF362C4BE9341CC97A2D06E92&t=2&fmt=- 安装好之后,用以下方法来注册: 在“添加删除”里面选择删除"visual studio 2 ...
  • 我的Visual Studio 2010的安装确实有“用户未处理”列: 编辑 从VS2008调试器不会打破未处理的异常 ... 事实证明,如果您没有在“调试”选项中选中“仅启用我的代码(仅管理)”,“用户未处理”列将不显示在“例外”对话框中。 My installation of Visual Studio 2010 does have the "User-unhandled" column: Edit From VS2008 Debugger does not break on unhandled exc ...
  • “待更改”工具窗口。 选择“视图”>“其他Windows”>“待更改”菜单项。 您也可以使用tf status命令,请参阅http://msdn.microsoft.com/en-us/library/9s5ae285.aspx 。 The "Pending Changes" toolwindow. Select the View > Other Windows > Pending Changes menu items. You can also use tf status command, see htt ...
  • 听起来像机器之间的不同DPI设置。 当我第一次在Win7中创建一个项目并在WinXP机器上运行它时,我注意到了这一点。 这是一篇SO帖子,描述了这个问题以及如何解决这个问题。 Sounds like different DPI settings between the machines. I noticed this when I first created a project in Win7 and ran it on a WinXP machine. Here is an SO post describ ...
  • 您可以使用以下代码行显示网格线: Application.DisplayGridLines = True 我正在看一种显示标尺的方法。 显示标尺的方案是什么? 是否要将按钮添加到显示标尺的自定义功能区? 如果是这种情况,您可以使用RibbonXML在自定义功能区中包含内置的“显示标尺”复选框。 http://msdn.microsoft.com/en-us/library/vstudio/aa942866.aspx You can display the grid lines with this line ...
  • 在NotExad ++等TextExitor中打开AudioPlayer.csproj,找到Form1.Designer.cs,然后添加DependentUpon节点: Form1.cs 根据您的上一条评论,有两个InitializeComponent方法,请验证两者并删除其中一个。 Open AudioPlayer.csproj in a T ...
  • 有几种选择: 您可以通过更改设置来使用SnapLines或SnapToGrid : 工具 - >选项 - > Windows窗体设计器 - >常规 - >布局模式(和ShowGrid,SnapToGrid) 请注意,您需要关闭并重新打开设计器才能使更改生效。 或者,您可以通过选择要对齐的对齐并使用“布局”工具栏上的对齐功能来对齐控件。 要显示“布局”工具栏,请右键单击工具栏的空白区域(然后您应该看到一长串可用工具栏),并选中“布局”复选框。 There are a couple of options: Yo ...
  • 我写了实用工具来手术清理TFS Team Explorer相关的东西。 在CodePlex上托管: http://tfsremover.codeplex.com/ 随意尝试一下。 在我的VS.NET 2010 Ultimate上完美运行。 I've written utility to surgically clean up TFS Team Explorer related stuff. Hosted on CodePlex: http://tfsremover.codeplex.com/ Feel fr ...
  • 我通过抽象一切来解决这个问题。 在表示层我会有一个服务抽象... public interface IServiceAgent { Task GetSomething(string myParameter); } ...从Web API中抽象出我想要的东西。 演示者不需要协调请求。 演示者不关心数据来自何处。 它所知道的是它需要一些东西并要求它(SoC)。 这是服务代理的工作(SRP)。 服务代理实现可能需要调用不同的数据源。 包括网络。 因此,抽象HttpCl ...
  • 我相信你最好的选择是将xsd.exe作为预构建事件运行,并将XSD的构建操作设置为“None”。 I believe your best bet would be to run xsd.exe as a pre-build event, and setting the build action for your XSD to "None".

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)