Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

MediaSource Class Reference
(Phonon::MediaSource)
[Phonon module]

provides multimedia data for MediaObjects. More...

 #include <Phonon>

Public Types

Public Functions


Detailed Description

Author: Matthias Kretz <kretz@kde.org>

provides multimedia data for MediaObjects.

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. Note that it is possible to provide data from any source by implementing an AbstractMediaStream.

The class has several functions to acquire information about the source it manages, e.g., fileName(), url(), and diskType(). 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);

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.


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 a URL, which can be either a local file or a file on the network.
Phonon::MediaSource::Disc2The MediaSource object describes a disc.
Phonon::MediaSource::Stream3The MediaSource object describes a data stream. This is also the type used for QIODevices.

See also MediaSource::type() and AbstractMediaStream.


Member Function Documentation

MediaSource::MediaSource ()

Creates an invalid MediaSource object.

See also Invalid.

MediaSource::MediaSource ( const QString & fileName )

Creates a MediaSource object for a local file or a Qt resource.

fileName file name of a local media file or a Qt resource that was compiled in.

MediaSource::MediaSource ( const QUrl & url )

Creates a MediaSource object for a URL.

url URL to a media file or stream.

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

Creates a MediaSource object for discs.

discType See DiscType deviceName A platform dependent device name. This can be useful if the computer has more than one CD drive. It is recommended to use Solid to retrieve the device name in a portable way.

MediaSource::MediaSource ( AbstractMediaStream * stream )

Creates a MediaSource object for a data stream.

Your application can provide the media data by subclassing AbstractMediaStream and passing a pointer to that object. Phonon will never delete the stream.

stream The AbstractMediaStream subclass to provide the media data.

See also setAutoDelete.

MediaSource::MediaSource ( QIODevice * ioDevice )

Creates a MediaSource object for a QIODevice.

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

ioDevice An arbitrary readable QIODevice subclass. If the device is not opened MediaSource will open it as QIODevice::ReadOnly. Sequential I/O devices are possible, too. For those MediaObject::isSeekable() will have to return false obviously.

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.

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().

Phonon::DiscType MediaSource::discType () const

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

QString MediaSource::fileName () const

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

void MediaSource::setAutoDelete ( bool enable )

Tell the MediaSource to take ownership of the AbstractMediaStream or QIODevice that was passed in the constructor.

The default setting is false, for safety. If you turn it on, you should only access the AbstractMediaStream/QIODevice object as long as you keep a MediaSource object around. As long as you keep the MediaSource object wrapping the stream/device the object will not get deleted.

See also autoDelete().

AbstractMediaStream * MediaSource::stream () const

Returns the media stream of the MediaSource if type() == Stream; otherwise returns 0. QIODevices are handled as streams, too.

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().

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.


Copyright © 2008 Trolltech Trademarks
Qt 4.4.0-beta1