BatteryManager.dischargingTime
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
Indíca la cantidad de tiempo, en segundos, que restan antes de que la batería se descargue completamente.
Nota: Incluso si el tiempo devuelto es exacto al segundo, los navegadores los redondean a un intervalo más alto (típicamente a los 15 minutos más cercanos) por razones de privacidad.
Sintaxis
js
var time = battery.dischargingTime;
Valor de retorno, time es el tiempo restante en segundos antes que la battery,
que es un objeto BatteryManager,
esté completamente descargada y el sistema se suspenda.
Este valor es Infinity
Si la batería se está cargando en vez de descargando,
o si el sistema es incapaz de calcular el tiempo de descarga.
Ejemplo
>Contenido HTML
html
<div id="dischargingTime">(tiempo de descarga desconocido)</div>
Contenido JavaScript
js
navigator.getBattery().then(function (battery) {
var time = battery.dischargingTime;
document.querySelector("#dischargingTime").textContent =
battery.dischargingTime;
});
Resultado
Especificaciones
| Specification |
|---|
| Battery Status API> # dom-batterymanager-dischargingtime> |