1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/webidl/FMRadio.webidl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +interface FMRadio : EventTarget { 1.9 + /* Indicates if the FM radio is enabled. */ 1.10 + readonly attribute boolean enabled; 1.11 + 1.12 + /* Indicates if the antenna is plugged and available. */ 1.13 + readonly attribute boolean antennaAvailable; 1.14 + 1.15 + /** 1.16 + * Current frequency in MHz. The value will be null if the FM radio is 1.17 + * disabled. 1.18 + */ 1.19 + readonly attribute double? frequency; 1.20 + 1.21 + /* The upper bound of frequency in MHz. */ 1.22 + readonly attribute double frequencyUpperBound; 1.23 + 1.24 + /* The lower bound of frequency in MHz. */ 1.25 + readonly attribute double frequencyLowerBound; 1.26 + 1.27 + /** 1.28 + * The difference in frequency between two "adjacent" channels, in MHz. That 1.29 + * is, any two radio channels' frequencies differ by at least channelWidth 1.30 + * MHz. Usually, the value is one of: 1.31 + * - 0.05 MHz 1.32 + * - 0.1 MHz 1.33 + * - 0.2 MHz 1.34 + */ 1.35 + readonly attribute double channelWidth; 1.36 + 1.37 + /* Fired when the FM radio is enabled. */ 1.38 + attribute EventHandler onenabled; 1.39 + 1.40 + /* Fired when the FM radio is disabled. */ 1.41 + attribute EventHandler ondisabled; 1.42 + 1.43 + /** 1.44 + * Fired when the antenna becomes available or unavailable, i.e., fired when 1.45 + * the antennaAvailable attribute changes. 1.46 + */ 1.47 + attribute EventHandler onantennaavailablechange; 1.48 + 1.49 + /* Fired when the FM radio's frequency is changed. */ 1.50 + attribute EventHandler onfrequencychange; 1.51 + 1.52 + /** 1.53 + * Power the FM radio off. The disabled event will be fired if this request 1.54 + * completes successfully. 1.55 + */ 1.56 + DOMRequest disable(); 1.57 + 1.58 + /** 1.59 + * Power the FM radio on, and tune the radio to the given frequency in MHz. 1.60 + * This will fail if the given frequency is out of range. The enabled event 1.61 + * and frequencychange event will be fired if this request completes 1.62 + * successfully. 1.63 + */ 1.64 + DOMRequest enable(double frequency); 1.65 + 1.66 + /** 1.67 + * Tune the FM radio to the given frequency. This will fail if the given 1.68 + * frequency is out of range. 1.69 + * 1.70 + * Note that the FM radio may not tuned to the exact frequency given. To get 1.71 + * the frequency the radio is actually tuned to, wait for the request to fire 1.72 + * sucess (or wait for the frequencychange event to fire), and then read the 1.73 + * frequency attribute. 1.74 + */ 1.75 + DOMRequest setFrequency(double frequency); 1.76 + 1.77 + /** 1.78 + * Tell the FM radio to seek up to the next channel. If the frequency is 1.79 + * successfully changed, the frequencychange event will be triggered. 1.80 + * 1.81 + * Only one seek is allowed at once: If the radio is seeking when the seekUp 1.82 + * is called, error will be fired. 1.83 + */ 1.84 + DOMRequest seekUp(); 1.85 + 1.86 + /** 1.87 + * Tell the FM radio to seek down to the next channel. If the frequency is 1.88 + * successfully changed, the frequencychange event will be triggered. 1.89 + * 1.90 + * Only one seek is allowed at once: If the radio is seeking when the 1.91 + * seekDown is called, error will be fired. 1.92 + */ 1.93 + DOMRequest seekDown(); 1.94 + 1.95 + /** 1.96 + * Cancel the seek action. If the radio is not currently seeking up or down, 1.97 + * error will be fired. 1.98 + */ 1.99 + DOMRequest cancelSeek(); 1.100 +}; 1.101 +