Access radio functionality from a QML application. 更多...
import 语句: | import QtMultimedia 5.8 |
继承: | Item |
Rectangle { width: 320 height: 480 Radio { id: radio band: Radio.FM } MouseArea { x: 0; y: 0 height: parent.height width: parent.width / 2 onClicked: radio.scanDown() } MouseArea { x: parent.width / 2; y: 0 height: parent.height width: parent.width / 2 onClicked: radio.scanUp() } }
可以使用
Radio
to tune the radio and get information about the signal. You can also use the Radio to get information about tuning, for instance the frequency steps supported for tuning.
The corresponding
RadioData
gives RDS information about the current radio station. The best way to access the
RadioData
for the current Radio is to use the
radioData
特性。
另请参阅 无线电概述 .
This property is true if there is an antenna connected. Otherwise it will be false.
Returns the availability state of the radio.
This is one of:
值 | 描述 |
---|---|
Available | The radio is available to use |
Busy | The radio is usually available to use, but is currently busy. This can happen when some other process needs to use the audio hardware. |
Unavailable | The radio is not available to use (there may be no radio hardware) |
ResourceMissing | There is one or more resources missing, so the radio cannot be used. It may be possible to try again at a later time. This can occur if there is no antenna connected - see the antennaConnected property as well. |
This property holds the frequency band used for the radio, which can be specified as any one of the values in the table below.
值 | 描述 |
---|---|
AM | 520 to 1610 kHz, 9 or 10kHz channel spacing, extended 1610 to 1710 kHz |
FM | 87.5 to 108.0 MHz, except Japan 76-90 MHz |
SW | 1.711 to 30.0 MHz, divided into 15 bands. 5kHz channel spacing |
LW | 148.5 to 283.5 kHz, 9kHz channel spacing (Europe, Africa, Asia) |
FM2 | range not defined, used when area supports more than one FM range |
Sets the frequency in Hertz that the radio is tuned to. The frequency must be within the frequency range for the current band, otherwise it will be changed to be within the frequency range.
另请参阅 maximumFrequency and minimumFrequency .
The number of Hertz for each step when tuning the radio manually. The value is for the current band .
The maximum frequency for the current band .
The minimum frequency for the current band .
This property reflects whether the radio is muted or not.
This property is true if the radio is currently searching for radio stations, for instance using the scanUp , scanDown ,和 searchAllStations methods. Once the search completes, or if it is cancelled using cancelScan , this property will be false.
The strength of the current radio signal as a percentage where 0% equals no signal, and 100% is a very good signal.
This property holds the current state of the Radio.
值 | 描述 |
---|---|
ActiveState | The radio is started and active |
StoppedState | The radio is stopped |
This property holds whether the radio is receiving a stereo signal or not. If stereoMode is set to ForceMono the value will always be false. Likewise, it will always be true if stereoMode is set to ForceStereo.
另请参阅 stereoMode .
This property holds the stereo mode of the radio, which can be set to any one of the values in the table below.
值 | 描述 |
---|---|
Auto | Uses stereo mode matching the station |
ForceStereo | Forces the radio to play the station in stereo, converting the sound signal if necessary |
ForceMono | Forces the radio to play the station in mono, converting the sound signal if necessary |
Set this property to control the volume of the radio. The valid range of the volume is from 0 to 100.
This signal is emitted when a new radio station is found. This signal is only emitted if
searchAllStations
is called with
SearchGetStationId
.
The frequency is returned in Hertz, and the stationId corresponds to the station Id in the RadioData for this radio station.
相应处理程序是
onStationFound
.
Cancel the current scan. Will also cancel a search started with searchAllStations .
Searches backward in the frequency range for the current band.
Searches forward in the frequency range for the current band.
Start searching the complete frequency range for the current band, and save all the radio stations found. The search mode can be either of the values described in the table below.
值 | 描述 |
---|---|
SearchFast | Stores each radio station for later retrival and tuning |
SearchGetStationId | Does the same as SearchFast, but also emits the station Id with the stationFound 信号。 |
The snippet below uses
searchAllStations
with
SearchGetStationId
to receive all the radio stations in the current band, and store them in a
ListView
. The station Id is shown to the user and if the user presses a station, the radio is tuned to this station.
Item { width: 640 height: 360 Radio { id: radio onStationFound: radioStations.append({"frequency": frequency, "stationId": stationId}) } ListModel { id: radioStations } ListView { model: radioStations delegate: Rectangle { MouseArea { anchors.fill: parent onClicked: radio.frequency = frequency } Text { anchors.fill: parent text: stationId } } } Rectangle { MouseArea { anchors.fill: parent onClicked: radio.searchAllStations(Radio.SearchGetStationId) } } }
Starts the radio. If the radio is available, as determined by the
availability
property, this will result in the
state
becoming
ActiveState
.
Stops the radio. After calling this method the
state
将是
StoppedState
.
Decrements the frequency by the frequency step for the current band. If the frequency is already set to the minimum frequency, calling this function has no effect.
另请参阅 band , frequencyStep ,和 minimumFrequency .
Increments the frequency by the frequency step for the current band. If the frequency is already set to the maximum frequency, calling this function has no effect.
另请参阅 band , frequencyStep ,和 maximumFrequency .