为Android中的MP4分配目录缩略图图像?

为Android中的MP4分配目录缩略图图像?,android,thumbnails,mp4,Android,Thumbnails,Mp4,我正在尝试分配一个特定的缩略图来表示android目录中的媒体文件(mp4)。默认情况下,我相信android将使用第一帧 我尝试了元数据/标记,但没有结果 如果你有解决办法,请告诉我,我将永远感激你。谢谢大家! 这是我使用的代码的一部分: String filepath = "/yourFilePathHere/yourFileNameHere.ext"; File sourceFile = new File ( filepath ); IsoBufferWrapper isoBuffer

我正在尝试分配一个特定的缩略图来表示android目录中的媒体文件(mp4)。默认情况下,我相信android将使用第一帧

我尝试了元数据/标记,但没有结果

如果你有解决办法,请告诉我,我将永远感激你。谢谢大家!

这是我使用的代码的一部分:

String filepath = "/yourFilePathHere/yourFileNameHere.ext";
File sourceFile = new File ( filepath );

IsoBufferWrapper isoBufferWrapper = new IsoBufferWrapperImpl( sourceFile );
IsoFile isoFile = new IsoFile(isoBufferWrapper);
isoFile.parse();

AppleItemListBox appleItemListBox = (AppleItemListBox) IsoFileConvenienceHelper.get(isoFile, "moov/udta/meta/ilst");
AppleCoverBox coverBox = (AppleCoverBox) IsoFileConvenienceHelper.get (appleItemListBox, AppleCoverBox.TYPE);

List<Box> dataBoxes = coverBox.getBoxes();
byte[] coverBoxByte = null;
if (dataBoxes != null && dataBoxes.size() > 0) {
    AppleDataBox dataBox = (AppleDataBox)dataBoxes.get(0);
    coverBoxByte = dataBox.getContent();
}

Bitmap icon = null;
if (coverBoxByte != null){
    icon = BitmapFactory.decodeByteArray(coverBoxByte, 0, coverBoxByte.length);
}
String filepath=“/yourFilePathHere/yourFileNameHere.ext”;
文件源文件=新文件(文件路径);
IsoBufferWrapper IsoBufferWrapper=新的IsoBufferWrapperImpl(源文件);
IsoFile IsoFile=新的IsoFile(isoBufferWrapper);
parse();
AppleItemListBox AppleItemListBox=(AppleItemListBox)isoFile便利性帮助.get(isoFile,“moov/udta/meta/ilst”);
AppleCoverBox coverBox=(AppleCoverBox)isofile便利性help.get(appleItemListBox,AppleCoverBox.TYPE);
List databox=coverBox.getbox();
字节[]coverBoxByte=null;
if(databox!=null&&databox.size()>0){
AppleDataBox dataBox=(AppleDataBox)dataBox.get(0);
coverBoxByte=dataBox.getContent();
}
位图图标=空;
if(coverBoxByte!=null){
icon=BitmapFactory.decodeByteArray(coverBoxByte,0,coverBoxByte.length);
}