1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 interface FMRadio : EventTarget {
6 /* Indicates if the FM radio is enabled. */
7 readonly attribute boolean enabled;
9 /* Indicates if the antenna is plugged and available. */
10 readonly attribute boolean antennaAvailable;
13 * Current frequency in MHz. The value will be null if the FM radio is
16 readonly attribute double? frequency;
18 /* The upper bound of frequency in MHz. */
19 readonly attribute double frequencyUpperBound;
21 /* The lower bound of frequency in MHz. */
22 readonly attribute double frequencyLowerBound;
25 * The difference in frequency between two "adjacent" channels, in MHz. That
26 * is, any two radio channels' frequencies differ by at least channelWidth
27 * MHz. Usually, the value is one of:
32 readonly attribute double channelWidth;
34 /* Fired when the FM radio is enabled. */
35 attribute EventHandler onenabled;
37 /* Fired when the FM radio is disabled. */
38 attribute EventHandler ondisabled;
41 * Fired when the antenna becomes available or unavailable, i.e., fired when
42 * the antennaAvailable attribute changes.
44 attribute EventHandler onantennaavailablechange;
46 /* Fired when the FM radio's frequency is changed. */
47 attribute EventHandler onfrequencychange;
50 * Power the FM radio off. The disabled event will be fired if this request
51 * completes successfully.
56 * Power the FM radio on, and tune the radio to the given frequency in MHz.
57 * This will fail if the given frequency is out of range. The enabled event
58 * and frequencychange event will be fired if this request completes
61 DOMRequest enable(double frequency);
64 * Tune the FM radio to the given frequency. This will fail if the given
65 * frequency is out of range.
67 * Note that the FM radio may not tuned to the exact frequency given. To get
68 * the frequency the radio is actually tuned to, wait for the request to fire
69 * sucess (or wait for the frequencychange event to fire), and then read the
70 * frequency attribute.
72 DOMRequest setFrequency(double frequency);
75 * Tell the FM radio to seek up to the next channel. If the frequency is
76 * successfully changed, the frequencychange event will be triggered.
78 * Only one seek is allowed at once: If the radio is seeking when the seekUp
79 * is called, error will be fired.
84 * Tell the FM radio to seek down to the next channel. If the frequency is
85 * successfully changed, the frequencychange event will be triggered.
87 * Only one seek is allowed at once: If the radio is seeking when the
88 * seekDown is called, error will be fired.
90 DOMRequest seekDown();
93 * Cancel the seek action. If the radio is not currently seeking up or down,
94 * error will be fired.
96 DOMRequest cancelSeek();