public class RadioManager
extends java.lang.Object
The frequency modulation (FM) band range is 87.5 to 108 MHz, and the amplitude modulation (AM) band range is 531 to 1602 kHz.
SystemCapability.Multimedia#FM_RADIO| 构造器 | 说明 |
|---|---|
RadioManager() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static int |
cancel() |
Cancels the search for radio station.
|
static BandConfig |
getBandConfig() |
Obtains registration information about the radio sation.
|
static int |
getMode() |
Obtains the radio band type that has been set.
|
static ProgramInfo |
getProgramInfo() |
Obtains information about the current radio station.
|
static int |
seek(DirectionType direction,
ICallback callback) |
Seeks for a radio frequency based on the adjustment direction set by the user.
|
static int |
setMode(ModeType mode) |
Sets the radio band type.
|
static int |
step(DirectionType direction,
ICallback callback) |
Adjusts the radio frequency by fixed value.
|
static int |
tune(int channel,
ICallback callback) |
Tunes to the radio frequency set by the user.
|
public static int setMode(ModeType mode) throws java.lang.IllegalArgumentException, ohos.rpc.RemoteException
When this method is called for the first time, AM and FM wave freqencies are set to their minimum values by default.
mode - Indicates the radio band type. Value 0 indicates FM broadcasting,
1 indicates AM broadcasting, and 2 indicates an invalid type.0 if the setting is successful; returns other values otherwise.ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.IllegalArguementException - Throws this exception if the application
does not have the ohos.permission.radio.ACCESS_FM_AM permission.java.lang.IllegalArgumentExceptionpublic static int getMode()
throws java.lang.IllegalArgumentException,
ohos.rpc.RemoteException
0 indicates FM broadcasting,
and 1 indicates AM broadcasting.ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.IllegalArguementException - Throws this exception if the application
does not have the ohos.permission.radio.ACCESS_FM_AM permission.java.lang.IllegalArgumentExceptionpublic static int step(DirectionType direction, ICallback callback) throws java.lang.IllegalArgumentException, ohos.rpc.RemoteException
The fixed value for increasing or decreasing an AM frequency is 9 Hz, and that for FM is 10 Hz.
If the AM frequency is already the minimum frequency of the band range (531 kHz) and you set
direction to 0, the target AM frequency will be the maximum frequency of the
band range (1602 kHz).This also works for an FM frequency.
direction - Indicates the adjustment direction. Value 0 indicates that the frequency
will be decreased by fixed value, and 1 indicates that the frequency will be increased by
fixed value.callback - Indicates the callback that received radio program information.0 if the operation is successful; returns other values otherwise.ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.java.lang.IllegalArgumentException - Throws this exception if the callback is null or the application
does not have the ohos.permission.radio.ACCESS_FM_AM permission.public static int seek(DirectionType direction, ICallback callback) throws java.lang.IllegalArgumentException, ohos.rpc.RemoteException
direction - Indicates the adjustment direction. Value 0 indicates that
the frequency will be decreased, and 1 indicates that the frequency will be increased.callback - Indicates the callback that received radio program information.0 if the operation is successful; returns other values otherwise.ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.java.lang.IllegalArgumentException - Throws this exception if the callback is null or the
application does not have the ohos.permission.radio.ACCESS_FM_AM permission.public static int tune(int channel,
ICallback callback)
throws java.lang.IllegalArgumentException,
ohos.rpc.RemoteException
channel - Indiactes the target radio frequency.callback - Indicates the callback that received radio program information.0 if the operation is successful; returns other values otherwise.ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.java.lang.IllegalArgumentException - Throws this exception if the callback is null
or the application does not have the ohos.permission.radio.ACCESS_FM_AM permission.public static int cancel()
throws java.lang.IllegalArgumentException,
ohos.rpc.RemoteException
0 if the search is canceled; returns other values otherwise.ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.IllegalArguementException - Throws this exception if the application does not have the
ohos.permission.radio.ACCESS_FM_AM permission.java.lang.IllegalArgumentExceptionpublic static ProgramInfo getProgramInfo() throws java.lang.IllegalArgumentException, ohos.rpc.RemoteException
ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.IllegalArguementException - Throws this exception if the application does not have the
ohos.permission.radio.ACCESS_FM_AM permission.java.lang.IllegalArgumentExceptionpublic static BandConfig getBandConfig() throws java.lang.IllegalArgumentException, ohos.rpc.RemoteException
ohos.rpc.RemoteException - Throws this exception if the underlying IPC communication fails.IllegalArguementException - Throws this exception if the application does not have
the ohos.permission.radio.ACCESS_FM_AM permission.java.lang.IllegalArgumentException