camera.listFiles
列出相机中的所有图片/所有视频/所有图片和视频。这可能需要
多个请求来列出所有文件。此命令是在 API 级别 2 中添加的。
如果摄像头不支持所请求的参数,则必须返回
硬件可用的最大功能。例如,在极少数情况下
请求:{entryCount: 500, maxSize: 2000}
。系统不会抛出错误
应基于相机支持的最大功能,
例如 {entryCount: 100, maxSize: 200}
。请为所有其他
案件;例如,当请求为 {entryCount: 500, maxSize: -500}
时,
应抛出错误 invalidParameterValue
,因为 maxSize
为负数。
参数
- fileType:要列出的文件的类型,应为以下任何一项
三个字段:“图片”“视频”“全部”
- startPosition::(可选)要添加到的第一个文件的位置
返回的值。如果省略,则起始位置为 0,
第一个文件。如果它大于最后一个文件的位置,则返回
结果中包含空白条目的正常响应,而不是错误响应。
- entryCount::要返回的条目数。如果
超过剩余文件数,则仅返回包含
实际剩余的文件,而不是错误响应。
- maxThumbSize::缩略图的大小上限;
max(thumbnail_width, thumbnail_height)。如果客户端
null
希望从结果中省略缩略图。
结果
- entries:图片属性的列表。每个条目应包含以下字段
但纬度和经度是可选项:
<ph type="x-smartling-placeholder">
</ph>
- name:文件的名称。
- fileUrl::文件的绝对网址,可用于直接从相机下载。
- size:文件的大小(以字节为单位)。
- dateTimeZone:文件的日期、时间和时区,格式为:
YYYY:MM:DD HH:MM:SS+(-)HH:MM
。时间采用 24 小时制。日期和
由一个空白字符分隔。时区与世界协调时间 (UTC) 相差。请注意
表示视频捕获的结束。
- lat:(可选)文件捕获时位置的纬度。
- lng:(可选)拍摄文件时位置的经度。
- width:图片或每个视频帧的宽度。
- height:图片或每个视频帧的高度。
- thumbnail:文件缩略图的 Base64 编码字符串(如果为
maxThumbSize != null
)。
- isProcessed:一个布尔值,指示文件是否
处理(例如拼接)或只是预览。通过
默认,除非
delayProcessing
设置为 true。如果存在经过处理的图片
不应列出相应的预览图片(即使存在),
否则,请列出预览图片。
- previewUrl::如果
delayProcessing
,则默认为空字符串
不受支持,或者当 isProcessed
等于 false 或预览图片时
从未作为中间结果生成,否则,该网址
与最终图片对应的预览图片。这用于构建
预览图片与最终图片之间的对应关系。
- totalEntries:中“
fileType
”的条目总数
存储空间,如如果 fileType 是“image”,那么它是
storage。
错误
- missing 参数:未指定任何必需参数;
例如,未指定
entryCount
。
- invalidParameterName:输入参数名称为
无法识别。
- invalidParameterValue::识别输入参数名称,
但其值无效;例如,
entryCount
为负数
或其数据类型不正确。
命令 I/O |
命令输入 |
{ "parameters": { "entryCount": 50, "maxThumbSize": 100 } } |
命令输出 |
{ "results": { "entries": [ { "name": "abc", "fileUrl": "file URL", "size": file size, # of bytes, "dateTimeZone": "2014:12:27 08:00:00+08:00", "lat": 50.5324, "lng": -120.2332, "width": 2000, "height": 1000, "thumbnail": "ENCODEDSTRING", "isProcessed": true, "previewUrl": "" } ... { ... } ], "totalEntries": 250 } } |
命令输出(错误) |
{ "error": { "code": "invalidParameterValue", "message": "Parameter entryCount is negative." } } |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-21。
[null,null,["最后更新时间 (UTC):2024-08-21。"],[[["Lists all images, videos, or both from the camera's storage, sorted by capture time in descending order."],["Allows retrieval of a specific number of files, starting from a designated position, with optional thumbnail generation."],["Returns file details like name, URL, size, capture timestamp, dimensions, and processing status."],["Includes error handling for missing or invalid parameters, prioritizing maximum camera capabilities over throwing errors when possible."],["Requires API level 2 or higher for compatibility."]]],["This command retrieves a list of files (images, videos, or both) from a camera's storage, sorted by capture time (newest first). Key actions involve specifying `fileType`, optional `startPosition`, desired `entryCount`, and `maxThumbSize`. The camera returns a list of `entries`, each with file details like name, URL, size, and capture time. Errors occur for invalid parameters, with the camera returning maximum supported capabilities for specific cases. Total entries are also provided.\n"]]