capture.stop()
停止摄像头或麦克风流,释放底层设备,并使句柄立即失效。重复停止幂等。
Syntax
await host.capture.stop(handle);
Parameters
handle:本应用持有的 camera-stream 或 microphone-stream close 句柄。
Return value
无。句柄立即失效;若应用声明了 capture.ended,宿主随后发送一次 reason 为 stopped 的事件。
Examples
stopButton.onclick = async () => {
await host.capture.stop(camera);
camera = null;
};
Errors
特有错误:stale-handle、resource-denied。已经停止的同一句柄不报错。
Requirements
- 授权:
handle-derived,不进入 manifest capability 列表 - 用户激活:不需要
- 信任档位:yellow