0
我想分配一个特定的缩略图图像来表示android目录内的媒体文件(mp4)。默认情况下,我相信android会使用第一帧。在Android中为MP4分配目录缩略图图像?
我试过元数据/标签无济于事。
请让我知道,如果你有一个解决方案,我会永远在你的感激之情。谢谢!
我想分配一个特定的缩略图图像来表示android目录内的媒体文件(mp4)。默认情况下,我相信android会使用第一帧。在Android中为MP4分配目录缩略图图像?
我试过元数据/标签无济于事。
请让我知道,如果你有一个解决方案,我会永远在你的感激之情。谢谢!
http://code.google.com/p/mp4parser/
这是我所使用的代码的一部分:
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);
}