navigator.b2g.fmRadio
#
DescriptionThe WebFM API provides access to the device FM radio. This interface lets you turn the FM radio on and off and tune it to different stations. It is accessible through the navigator.b2g.fmRadio property.
#
API Overview#
PropertiesFMRadio.enabled
Indicates whether the radio is playing.
FMRadio.antennaAvailable
Indicate if an antenna is plugged and available.
FMRadio.frequency
Current radio frequency..
FMRadio.frequencyUpperBound
Maximum frequency up to which the seek method searches for radio stations.
FMRadio.frequencyLowerBound
Minimum frequency down to which the seek method searches for radio stations.
FMRadio.channelWidth
The channel width of the ranges of frequency, in MHz.
#
Event handlersFMRadio.onenabled
Current radio frequency..
FMRadio.ondisabled
A handler for the enabled event; It is triggered when the radio has been turned on.
FMRadio.onantennaavailablechange
A handler for the antennaavailablechange event; It is triggered when an antenna is plugged or unplugged.
FMRadio.onfrequencychange
A handler for the frequencychange event; It is triggered whenever the radio frequency is changed.
#
MethodsFMRadio.enable()
Turns on the radio on the given frequency. This function throws if called with no argument. Returns a DOMRequest for the success or error of the operation.
FMRadio.disable()
Turns the radio off. Returns a DOMRequest which success indicates that the radio has properly been disabled.
FMRadio.setFrequency()
Asynchronously changes the radio frequency. The value has to be between frequencyLowerBound and frequencyUpperBound. Trying to set outside the bounds results in an error.
Returns a DOMRequest which success indicates the frequency has properly been changed.
FMRadio.seekUp()
Asks the radio to find a new frequency (usually greater than the current one). If one is successfully found, a frequencychange event is fired. Returns a DOMRequest which success indicates that the search has started. The search circles back to lower frequencies when the highest frequency has been reached.
FMRadio.seekDown()
Same as above, but searching in frequencies lower than the current one. The search cirlces back to higher frequencies when the lowest frequency has been reached.
FMRadio.cancelSeek()
Cancels the radio seek if one was happening. Returns a DOMRequest which success indicates that the frequency search has been cancelled.