• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. B2G OS APIs
  5. FMRadio
  6. FMRadio.setFrequency()

FMRadio.setFrequency()

In This Article
  1. Summary
  2. Syntax
    1. Parameters
    2. Returns
  3. Example
  4. Specification
  5. See also

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

Document Tags and Contributors

Tags: 
  • API
  • Firefox OS
  • FMRadio API
  • Method
  • Non Standard
  • Reference
  • Référence
  • WebFM
 Contributors to this page: chrisdavidmills, teoli, kscarfone, Jeremie
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:07:38 AM
See also
  1. WebFM API
  2. Archive
  3. Events
    1. antennaavailablechange
    2. frequencychange
    3. disabled
    4. enabled
  4. Related pages for FMRadio API
    1. FMRadio