Phonon.MediaSource

Synopsis

Functions

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 Phonon.MediaObject .

The media source knows how fetch its data from several sources, e.g., from files, a PySide.QtCore.QIODevice , or a CD. The possible source types are described by the Phonon.MediaSource.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 PySide.QtCore.QIODevice .

The class has several functions to acquire information about the source it manages, e.g., PySide.phonon.Phonon::MediaSource.fileName() and PySide.phonon.Phonon::MediaSource.url() . The return from these functions are dependent on the PySide.phonon.Phonon::MediaSource.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 Phonon.MediaObject .

m = MediaObject()
fileName = "/home/foo/bar.ogg"
url = QUrl("http://www.example.com/stream.mp3")
someBuffer = QBuffer()
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 Phonon Module

class PySide.phonon.Phonon.MediaSource
class PySide.phonon.Phonon.MediaSource(stream)
class PySide.phonon.Phonon.MediaSource(discType[, deviceName=""])
class PySide.phonon.Phonon.MediaSource(ioDevice)
class PySide.phonon.Phonon.MediaSource(device)
class PySide.phonon.Phonon.MediaSource(rhs)
class PySide.phonon.Phonon.MediaSource(device)
class PySide.phonon.Phonon.MediaSource(access)
class PySide.phonon.Phonon.MediaSource(fileName)
class PySide.phonon.Phonon.MediaSource(url)
Parameters:

Creates an invalid MediaSource object.

See also

Invalid

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

Creates a MediaSource object for the PySide.QtCore.QIODevice specified by ioDevice .

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

If you need to fetch multimedia data from a source that is not supported by MediaSource , you should subclass PySide.QtCore.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 PySide.QtCore.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 PySide.QtCore.QIODevice s 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 PySide.QtCore.QFile internally).

See also

PySide.phonon.Phonon::MediaSource.setAutoDelete()

Constructs a copy of the other media source.

This constructor is fast thanks to explicit sharing.

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

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.

PySide.phonon.Phonon.MediaSource.Type

Identifies the type of media described by the MediaSource object.

Constant Description
Phonon.MediaSource.Invalid The MediaSource object does not describe any valid source.
Phonon.MediaSource.LocalFile The MediaSource object describes a local file.
Phonon.MediaSource.Url The MediaSource object describes an URL, which can be either a local file or a file on the network.
Phonon.MediaSource.Disc The MediaSource object describes a disc, e.g., a CD.
Phonon.MediaSource.Stream The MediaSource object describes a data stream. This is the type used for PySide.QtCore.QIODevice s. Note that a stream opened with a PySide.QtCore.QUrl , will still be of the Url type.
Phonon.MediaSource.Empty The media source doesn’t have a source.

See also

MediaSource.type()

PySide.phonon.Phonon.MediaSource.audioCaptureDevice()
Return type:PySide.phonon.Phonon::AudioCaptureDevice
PySide.phonon.Phonon.MediaSource.autoDelete()
Return type:PySide.QtCore.bool

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

See also

PySide.phonon.Phonon::MediaSource.setAutoDelete()

PySide.phonon.Phonon.MediaSource.deviceAccessList()
Return type:
PySide.phonon.Phonon.MediaSource.deviceName()
Return type:unicode

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

See also

PySide.phonon.Phonon::MediaSource.type()

PySide.phonon.Phonon.MediaSource.discType()
Return type:PySide.phonon.Phonon.DiscType

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

See also

PySide.phonon.Phonon::MediaSource.type()

PySide.phonon.Phonon.MediaSource.fileName()
Return type:unicode

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

See also

PySide.phonon.Phonon::MediaSource.type()

PySide.phonon.Phonon.MediaSource.__eq__(rhs)
Parameters:rhsPySide.phonon.Phonon::MediaSource
Return type:PySide.QtCore.bool

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

PySide.phonon.Phonon.MediaSource.setAutoDelete(enable)
Parameters:enablePySide.QtCore.bool

If enable is true, the media source will take ownership of the object passed in the Phonon.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

PySide.phonon.Phonon::MediaSource.autoDelete()

PySide.phonon.Phonon.MediaSource.stream()
Return type:PySide.phonon.Phonon::AbstractMediaStream

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

PySide.phonon.Phonon.MediaSource.type()
Return type:PySide.phonon.Phonon::MediaSource.Type

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

See also

Phonon.MediaSource.Type

PySide.phonon.Phonon.MediaSource.url()
Return type:PySide.QtCore.QUrl

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

See also

PySide.phonon.Phonon::MediaSource.type()

PySide.phonon.Phonon.MediaSource.videoCaptureDevice()
Return type:PySide.phonon.Phonon::VideoCaptureDevice