Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

Radio

The Radio type allows you to access radio functionality from a QML application. More...

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

read-onlyantennaConnected : int

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


read-onlyavailability : 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.

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.


read-onlyfrequencyStep : int

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


read-onlymaximumFrequency : int

The maximum frequency for the current band.


read-onlyminimumFrequency : int

The minimum frequency for the current band.


muted : bool

This property reflects whether the radio is muted or not.


read-onlysearching : 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.


read-onlysignalStrength : int

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


read-onlystate : 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.


read-onlystereo : 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

Radio::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.


Method Documentation

Radio::cancelScan()

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


Radio::scanDown()

Searches backward in the frequency range for the current band.


Radio::scanUp()

Searches forward in the frequency range for the current band.


Radio::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)
         }
     }
 }

Radio::start()

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


Radio::stop()

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


Radio::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.


Radio::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.


Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web