Radio QML Type
Access radio functionality from a QML application. More...
Import Statement: | import QtMultimedia 5.8 |
Inherits: |
Properties
- antennaConnected : int
- availability : enumeration
- band : enumeration
- frequency : int
- frequencyStep : int
- maximumFrequency : int
- minimumFrequency : int
- muted : bool
- searching : bool
- signalStrength : int
- state : enumeration
- stereo : bool
- stereoMode : enumeration
- volume : int
Signals
- stationFound(int frequency, string stationId)
Methods
- cancelScan()
- scanDown()
- scanUp()
- searchAllStations(enumeration searchMode)
- start()
- stop()
- tuneDown()
- tuneUp()
Detailed Description
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() } }
You can use 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
property.
See also Radio Overview.
Property Documentation
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:
Value | Description |
---|---|
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.
Value | Description |
---|---|
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.
See also 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 is true if the radio is currently searching for radio stations, for instance using the scanUp, scanDown, and 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 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.
See also stereoMode.
This property holds the stereo mode of the radio, which can be set to any one of the values in the table below.
Value | Description |
---|---|
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.
Signal Documentation
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.
The corresponding handler is onStationFound
.
Method Documentation
Cancel the current scan. Will also cancel a search started with searchAllStations.
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.
Value | Description |
---|---|
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 signal. |
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 will be 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.
See also band, frequencyStep, and 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.
See also band, frequencyStep, and maximumFrequency.
© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.