我已经用它来创建我的视频缩略图.代码如下所示:
videoGalleryThumbnails.add(ThumbnailUtils.extractThumbnail(ThumbnailUtils.createVideoThumbnail(
videoFile.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND), 500, 200));
Run Code Online (Sandbox Code Playgroud)
但创建的缩略图是非常糟糕的时间.这恰好是视频是黑色的.现在我没有使用完全黑色的缩略图.
如何在特定时间拍摄视频缩略图?例如在00:31或01:44?
还是不可能?
我也尝试使用MediaMetadataRetriever,但我只得到一张白色图片.代码看起来像这样
File tempVideoList[] = (Environment.getExternalStoragePublicDirectory(PATH_VIDEO_GALLERY))
.listFiles();
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
Bitmap myBitmap=null;
for (File videoFile : tempVideoList) {
if (videoFile.isFile()) {
//from here
try {
retriever.setDataSource(videoFile.getAbsolutePath());
myBitmap = retriever.getFrameAtTime(11); //at 11th second
} catch (Exception ex) {
Log.i("MyDebugCode", "MediaMetadataRetriever got exception:" + ex);
}
videoGalleryThumbnails.add(myBitmap);
//to here
}
Run Code Online (Sandbox Code Playgroud)
如果我用顶部的第一个代码替换标记为"从这里"到"到这里"的代码,它就可以工作.我还尝试了MediaMetadataRetriever.OPTION_CLOSEST和OPTION_CLOSEST_SYNC以及OPTION_NEXT_SYNC.
所以我使用JavaScript,并且有一个变量数组。
var a=5,b=10,c=3,d=11,e=0; //5 Variables with randomly chosen values
var myArray=[a,b,c,d,e];
myArray.sort(); //sort them, so the lowest value or variable is on first place
alert("This Variable has the lowest value: " + myArray[0]);
//tell me the variable with the lowest value
Run Code Online (Sandbox Code Playgroud)
因此,基本上,我将得到以下文本:“此变量的最低值为:0”
但是我想要的是:“此变量的值最低:e”
我如何返回变量,而不是变量的值?
最好的问候qweret