java 如何在android中创建视频网址的缩略图?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13533857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how can I create a thumbnail of a video url in android?
提问by user1836363
I have a problem, I can only create thumbnails of local video files but not of a remote url, here is my code:
我有一个问题,我只能创建本地视频文件的缩略图,而不能创建远程 url,这是我的代码:
bmThumbnail = ThumbnailUtils.extractThumbnail(ThumbnailUtils.createVideoThumbnail("http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", MediaStore.Video.Thumbnails.MINI_KIND), 50, 50);
I hope you can help me,
我希望你能帮帮我,
regards christian
问候基督徒
采纳答案by sdabet
I suppose there is no easy way to build the thumbnail without actually downloading the video locally.
我想没有在本地实际下载视频的情况下没有简单的方法来构建缩略图。
So if your question is 'Can I get a thumbnail without having to download the full video?', I'd say...no.
因此,如果您的问题是“我可以在不必下载完整视频的情况下获取缩略图吗?”,我会说......不。
Otherwise, once you have downloaded the video locally, then I guess you can perfectly use ThumbnailUtils.createVideoThumbnail(...)
by giving the path to the downloaded file.
否则,一旦您在本地下载了视频,那么我想您可以ThumbnailUtils.createVideoThumbnail(...)
通过提供下载文件的路径来完美使用。
回答by Krzysztof Itaudit
I also have the same problem - but what can I say from my tests:
我也有同样的问题 - 但我能从我的测试中说些什么:
- The problem occurs only on android >2.3
- in android 2.0 -> 2.3 You can use just
- 该问题仅在 android >2.3 上发生
- 在 android 2.0 -> 2.3 你可以只使用
Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND);
Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND);
I hope someone explain what change is on android 4. it doesn't work
我希望有人解释一下 android 4 上有什么变化。它不起作用
回答by JesperB
I have no problem generating thumbnails from remote videos with the following code:
我使用以下代码从远程视频生成缩略图没有问题:
final Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND );
final Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND );
You don't have to wrap an extractThumbnail()
call around it
你不必extractThumbnail()
围绕它打个电话