2

I want to display thumbnails for a list of video files stored on external storage in my PhoneGap/Cordova application. Here's what I have so far:

  • PhoneGap does not have an API for this at present (May '12, PhoneGap 1.6.1). Correct?
  • I can get a video thumbnail from the local file path on Android 2.2+ (which I am already targeting) with ThumbnailUtils.createVideoTHumbnail()
  • I can temporarily save that thumbnail to internal storage (preferable in my mind) with a combination of Bitmap.compress() and Context.openFileOutput()

Simple enough, but then how do I access that file with PhoneGap? I can't seem to find where in the API docs it explains accessing the internal storage system for your app's data. Furthermore, is there a better way to do this entirely in memory without writing to the file system? I wouldn't mind discarding the thumbnail after I'm finished with it. I don't expect them to be accessed often.

Any help would be appreciated. Thanks!

Update:

Apparently Android generates thumbnail files for the gallery already, but the file names are just IDs. I keep seeing references to a "thumbnail database" that links these IDs to the respective file, but I can't find information on how to access it. Can someone please help me with an example or some documentation?

4

2 回答 2

2

如果有人正在寻找类似问题的答案,我最终所做的是:

function pickFile(callback) {
    var options = {
        quality: 100,
        destinationType: navigator.camera.DestinationType.FILE_URI,
        sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
        mediaType: navigator.camera.MediaType.VIDEO
    }
    function fail(error) {
        alert(error);
    }
    navigator.camera.getPicture(callback, fail, options);
}

这个选项显然是在 PhoneGap 1.1.0 中添加的,它允许您以独立于平台的方式从用户的图库中请求文件。在文档中查找不是很直观,并且您无法指定有关用户界面的任何内容,但总比没有好!我希望这可以帮助从谷歌来到这里的人。

干杯!

于 2012-05-22T01:41:31.943 回答
2

如果有人觉得这有帮助,我在 Andriod 上为 Phonegap 编写了一个小插件,用于创建捕获的图像和视频的缩略图: https ://github.com/maxbasmanov/phonegap_thumbnailer

于 2012-08-16T11:48:05.437 回答