aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/cameracontrol/autofocus/index.html
blob: 1ce3b547d3189a201a257856e1f9d4e1213dc9e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: CameraControl.autoFocus()
slug: Web/API/CameraControl/autoFocus
translation_of: Archive/B2G_OS/API/CameraControl/autoFocus
---
<p>{{APIRef("Camera API")}}{{ non-standard_header() }}{{B2GOnlyHeader2('privileged')}}</p>

<h2 id="Resumo">Resumo</h2>

<p>This method attempts to focus the camera. If the camera is able to attempt to focus, a success callback is issued, regardless of whether or not the focusing attempt succeeds. If unable to attempt to focus, an error callback is performed instead.</p>

<p>The success or failure of the focus operation is indicated by the value of a parameter passed into the callback function.</p>

<h2 id="Sintaxe">Sintaxe</h2>

<pre>CameraControl.autoFocus(onsuccess[, onerror]);</pre>

<h3 id="Parametros">Parametros</h3>

<dl>
 <dt><code>onsuccess</code></dt>
 <dd>A callback function called when a focus attempt is made</dd>
 <dt><code>onerror</code> {{optional_inline()}}</dt>
 <dd>An optional callback function that accepts an error string as an input parameter; this is called if it's not possible to attempt to focus the camera.</dd>
</dl>

<h2 id="Exemplo">Exemplo</h2>

<pre class="brush: js">function onFocusPossible( success ) {
  if ( success ) {
    console.log("The image has been focused");
  } else {
    console.log("The image has not been focused");
  }
}

function onFocusNotPossible( error ) {
  console.log("The camera is not able to focus anything");
  console.log( error );
}

function onAccessCamera( camera ) {
  camera.autoFocus(onFocusPossible, onFocusNotPossible);
};

var options = {
  camera: navigator.mozCameras.getListOfCameras()[0]
};

navigator.mozCameras.getCamera(options, onAccessCamera)
</pre>

<h2 id="Specification" name="Specification">Especificações</h2>

<p>Not part of any specification; however, this API should be removed when the <a class="external" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html" rel="external" title="http://dev.w3.org/2011/webrtc/editor/getusermedia.html">WebRTC Capture and Stream API</a> has been implemented.</p>

<h2 id="Leia_mais">Leia mais</h2>

<ul>
 <li>{{domxref("CameraControl")}}</li>
</ul>