Mrthumb
【拇指先生】 a simple easy video thumbnail provider,顺滑的获取视频缩略图,支持本地和网络视频
Install / Use
/learn @Reone/MrthumbREADME
拇指先生 Mrthumb
预览图
<div align="center"> <img src="https://raw.githubusercontent.com/Reone/Mrthumb/master/simple/preview.gif" height="580" width="320"> <img src="https://raw.githubusercontent.com/Reone/Mrthumb/master/simple/preview2.gif" height="580" width="320"> </div>库说明
- a simple easy video thumbnail provider
- 顺滑的获取视频缩略图
- 支持网络视频缩略图
- 使用方便
源码下载,分支说明
请下载对应版本号的分支下载源码浏览,master分支为代码最新状态,却不一定是生成库的源代码,而且有可能是有问题的代码。而生成库后的源码,我会新建一个对应版本号的分支,以保存库源码初始状态。一供查错,二供浏览。
原理说明
- 使用MediaMetadataRetriever获取视频信息及缩略图
- 使用MediaMetadataRetrieverCompat支持FFmpeg和自带两种解码方式
- 使用线程异步加载缩略图并缓存
- 支持两种不同的加载顺序选择:顺序、乱序
- 获取不到缩略图时取最近的缩略图
引用说明
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Reone:Mrthumb:v1.1.0'
}
使用说明
1.加载缩略图
if (playState == NiceVideoPlayer.STATE_PREPARED) {
//视频准备好后开始加载缩略图
Mrthumb.obtain().buffer(videoUrl, videoDuration, Mrthumb.Default.COUNT);
//更详细的可以调用如下方法
//Mrthumb.obtain().buffer(videoUrl, null, videoDuration, Mrthumb.Default.RETRIEVER_TYPE, Mrthumb.Default.COUNT, Mrthumb.Default.THUMBNAIL_WIDTH, Mrthumb.Default.THUMBNAIL_HEIGHT);
}
2.获取缩略图
float percentage = (float) seekBar.getProgress() / seekBar.getMax();
Bitmap bitmap = Mrthumb.obtain().getThumbnail(percentage);
3.添加缓存进度回调
Mrthumb.obtain().addProcessListener(new ProcessListener() {
@Override
public void onProcess(final int index, final int cacheCount, final int maxCount, final long time, final long duration) {
if (delegate != null) {
delegate.thumbProcessLog("cache " + time / 1000 + "s at " + index + " process:" + (cacheCount * 100 / maxCount) + "%");
}
}
});
4.回收资源
Mrthumb.obtain().release();
Related Skills
healthcheck
339.1kHost security hardening and risk-tolerance configuration for OpenClaw deployments
imsg
339.1kiMessage/SMS CLI for listing chats, history, and sending messages via Messages.app.
xurl
339.1kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
docs-writer
99.3k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
