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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

MediaSource Class Reference

(Phonon::MediaSource)

The MediaSource class provides multimedia data for media objects. More...

 #include <Phonon/MediaSource>

This class was introduced in Qt 4.4.

Public Types

enum Type { Invalid, LocalFile, Url, Disc, Stream, Empty }

Public Functions

MediaSource ( const QString & fileName )
MediaSource ( const QUrl & url )
MediaSource ( Phonon::DiscType discType, const QString & deviceName = QString() )
MediaSource ( QIODevice * ioDevice )
MediaSource ( const MediaSource & other )
~MediaSource ()
bool autoDelete () const
QString deviceName () const
Phonon::DiscType discType () const
QString fileName () const
void setAutoDelete ( bool enable )
Type type () const
QUrl url () const
MediaSource & operator= ( const MediaSource & other )
bool operator== ( const MediaSource & other ) const

Detailed Description

The MediaSource class provides multimedia data for media objects.

The MediaSource class manages a source of multimedia content, such as a music or video file, of which data is given to a MediaObject.

The media source knows how fetch its data from several sources, e.g., from files, a QIODevice, or a CD. The possible source types are described by the Type enum. The type of the source is set by the media source itself, and is dependent on the constructor used to create it. Note that it is possible to provide data from any source by implementing a QIODevice.

The class has several functions to acquire information about the source it manages, e.g., fileName() and url(). The return from these functions are dependent on the type() of the media source.

Normally, a programmer does not need to be concerned with media sources. It's constructors are implicit, so one can, for instance, send an URL or filename directly to the constructors of the MediaObject.

 MediaObject m;
 QString fileName("/home/foo/bar.ogg");
 QUrl url("http://www.example.com/stream.mp3");
 QBuffer *someBuffer;
 m.setCurrentSource(fileName);
 m.setCurrentSource(url);
 m.setCurrentSource(someBuffer);
 m.setCurrentSource(Phonon::Cd);

A MediaSource object cannot be reused for another multimedia source. It is possible to play the same source again, and also stop and start a non-seekable media source, such as a radio stream, with the same MediaSource object.

Qt Backends

Currently, Qt's backends support files in local and remote locations. Support for other sources, such as CD/DVD, are planned for the future.

See also MediaObject and Phonon Module.

Member Type Documentation

enum MediaSource::Type

Identifies the type of media described by the MediaSource object.

ConstantValueDescription
Phonon::MediaSource::Invalid-1The MediaSource object does not describe any valid source.
Phonon::MediaSource::LocalFile0The MediaSource object describes a local file.
Phonon::MediaSource::Url1The MediaSource object describes an URL, which can be either a local file or a file on the network.
Phonon::MediaSource::Disc2The MediaSource object describes a disc, e.g., a CD.
Phonon::MediaSource::Stream3The MediaSource object describes a data stream. This is the type used for QIODevices. Note that a stream opened with a QUrl, will still be of the Url type.
Phonon::MediaSource::Empty4The media source doesn't have a source.

See also MediaSource::type().

Member Function Documentation

MediaSource::MediaSource ( const QString & fileName )

Creates a MediaSource object for the file specified by fileName. You can also use this constructor with Qt resources

MediaSource::MediaSource ( const QUrl & url )

Creates a MediaSource object for a the URL specified by url.

If the multimedia content you would like to play back is on a remote network location, you should use this constructor; though, it also possible to specify an URL to a local file.

See also QUrl.

MediaSource::MediaSource ( Phonon::DiscType discType, const QString & deviceName = QString() )

Creates a MediaSource object for the type of disc specified by discType in the named device referred to by deviceName.

Note: deviceName is a platform dependent device name. It can be useful to specify this if the computer has more than one CD drive. On KDE, it is recommended to use the Solid hardware discovery framework to retrieve the device name in a portable way.

MediaSource::MediaSource ( QIODevice * ioDevice )

Creates a MediaSource object for the QIODevice specified by ioDevice.

This constructor can be very handy in the combination of QByteArray and QBuffer.

If you need to fetch multimedia data from a source that is not supported by MediaSource, you should subclass QIODevice and use this MediaSource constructor. It is important that you reimplement QIODevice::isSequential(), as it is used by MediaSource to determine if the media source is seekable.

ioDevice is an arbitrary readable QIODevice subclass. If the device is not opened MediaSource will open it as QIODevice::ReadOnly.

Note: Sequential devices can also be used, but MediaObject::isSeekable() will return false as a result.

Warning: On Windows, we only support QIODevices containing the avi, mp3, or mpg formats. Use the constructor that takes a file name to open files (the Qt backend does not use a QFile internally).

See also setAutoDelete().

MediaSource::MediaSource ( const MediaSource & other )

Constructs a copy of the other media source.

This constructor is fast thanks to explicit sharing.

MediaSource::~MediaSource ()

Destroys the MediaSource object. You should never delete a MediaSource yourself, the MediaObject will handle this.

bool MediaSource::autoDelete () const

Returns the setting of the auto-delete option. The default is false.

See also setAutoDelete().

QString MediaSource::deviceName () const

Returns the device name of the MediaSource if type() == Disc; otherwise returns QString().

See also type().

Phonon::DiscType MediaSource::discType () const

Returns the disc type of the MediaSource if type() == Disc; otherwise returns NoDisc.

See also type().

QString MediaSource::fileName () const

Returns the file name of the MediaSource if type() == LocalFile; otherwise, returns QString().

See also type().

void MediaSource::setAutoDelete ( bool enable )

If enable is true, the media source will take ownership of the object passed in the MediaSource's constructor object that was passed in the constructor; otherwise, the programmer is responsible for deletion of this object.

This setting is false by default. If you enable it, you should only access the stream or device as long as you keep the media source object around. As long as you keep the media source wrapping the stream or device, the object will not get deleted.

See also autoDelete().

Type MediaSource::type () const

Returns the type of the MediaSource (depends on the constructor that was used).

See also Type.

QUrl MediaSource::url () const

Returns the URL of the MediaSource if type() == URL or type() == LocalFile; otherwise returns QUrl().

See also type().

MediaSource & MediaSource::operator= ( const MediaSource & other )

Assigns the other media source to this media source and returns a reference to it.

This operation is fast thanks to explicit sharing.

bool MediaSource::operator== ( const MediaSource & other ) const

Returns true if this media source is equal to the other media source; otherwise returns false.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Labs au hasard

Logo

La folie est de mettre en forme le même texte

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 4.7
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