Radio QML Type

Access radio functionality from a QML application. More...

Import Statement: import QtMultimedia 5.4
Inherits:

Item

Properties

Signals

Methods

Detailed Description

Radio is part of the QtMultimedia 5.0 module.

import QtQuick 2.0
import QtMultimedia 5.0

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

antennaConnected : int

This property is true if there is an antenna connected. Otherwise it will be false.


availability : enumeration

Returns the availability state of the radio.

This is one of:

ValueDescription
AvailableThe radio is available to use
BusyThe radio is usually available to use, but is currently busy. This can happen when some other process needs to use the audio hardware.
UnavailableThe radio is not available to use (there may be no radio hardware)
ResourceMissingThere 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.

band : enumeration

This property holds the frequency band used for the radio, which can be specified as any one of the values in the table below.

ValueDescription
AM520 to 1610 kHz, 9 or 10kHz channel spacing, extended 1610 to 1710 kHz
FM87.5 to 108.0 MHz, except Japan 76-90 MHz
SW1.711 to 30.0 MHz, divided into 15 bands. 5kHz channel spacing
LW148.5 to 283.5 kHz, 9kHz channel spacing (Europe, Africa, Asia)
FM2range not defined, used when area supports more than one FM range

frequency : int

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.


frequencyStep : int

The number of Hertz for each step when tuning the radio manually. The value is for the current band.


maximumFrequency : int

The maximum frequency for the current band.


minimumFrequency : int

The minimum frequency for the current band.


muted : bool

This property reflects whether the radio is muted or not.


searching : bool

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.


signalStrength : int

The strength of the current radio signal as a percentage where 0% equals no signal, and 100% is a very good signal.


state : enumeration

This property holds the current state of the Radio.

ValueDescription
ActiveStateThe radio is started and active
StoppedStateThe radio is stopped

See also start and stop.


stereo : bool

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.


stereoMode : enumeration

This property holds the stereo mode of the radio, which can be set to any one of the values in the table below.

ValueDescription
AutoUses stereo mode matching the station
ForceStereoForces the radio to play the station in stereo, converting the sound signal if necessary
ForceMonoForces the radio to play the station in mono, converting the sound signal if necessary

volume : int

Set this property to control the volume of the radio. The valid range of the volume is from 0 to 100.


Signal Documentation

stationFound(int frequency, string stationId)

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

cancelScan()

Cancel the current scan. Will also cancel a search started with searchAllStations.


scanDown()

Searches backward in the frequency range for the current band.


scanUp()

Searches forward in the frequency range for the current band.


searchAllStations(enumeration searchMode)

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.

ValueDescription
SearchFastStores each radio station for later retrival and tuning
SearchGetStationIdDoes 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)
        }
    }
}

start()

Starts the radio. If the radio is available, as determined by the availability property, this will result in the state becoming ActiveState.


stop()

Stops the radio. After calling this method the state will be StoppedState.


tuneDown()

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.


tuneUp()

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.


© 2015 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.