FMRadio.setFrequency()
This API is available on Firefox or Firefox OS for installed or higher privileged applications.
Summary
The setFrequency
method is used to change the frequency listened to by the radio.
Each time this method is called successfully, the frequencychange
event is fired.
The frequency to set must be in the range defined by the frequencyLowerBound
and the frequencyUpperBound
properties.
When set, the actual frequency used by the radio is the frequency passed as input but rounded according to the value of the channelWidth
property.
Syntax
var request = instanceOfFMRadio.setFrequency(frequency);
Parameters
- frequency
- The value of the new frequency to set, It's a number representing a value in MHz (MegaHertz).
Returns
It returns a DOMRequest
to handle the success or error of the operation.
Example
var request = navigator.mozFMRadio.setFrequency(100.15); request.onsuccess = function () { console.log("The radio is now listening the frequency: " + navigator.mozFMRadio.frequency + "MHz"); } request.onerror = function () { console.log("Something goes wrong!"); }
Specification
Not part of any specification.
See also
FMRadio
FMRadio.frequency
FMRadio.channelWidth
FMRadio.frequencyLowerBound
FMRadio.frequencyUpperBound
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/fmradio/setfrequency