The AbstractMediaStream class is the base class for custom media data streams.
This class is subclassed to provide custom data streams for Phonon.MediaSource s.
The Phonon.MediaSource knows how to handle the most common media sources, such as files and CD. If you need to fetch multimedia from other sources, you can reimplement this class, which can be used by a Phonon.MediaSource .
When a backend needs more data from the stream, PySide.phonon.Phonon::AbstractMediaStream.needData() will be called. You must then use PySide.phonon.Phonon::AbstractMediaStream.writeData() to write the data to the backend. You can either write one time and wait for a new PySide.phonon.Phonon::AbstractMediaStream.needData() call, or continue to write data until you receive an PySide.phonon.Phonon::AbstractMediaStream.enoughData() call. When the stream is at its end, call PySide.phonon.Phonon::AbstractMediaStream.endOfData() instead of PySide.phonon.Phonon::AbstractMediaStream.writeData() .
Before the custom stream is passed to a Phonon.MediaSource , PySide.phonon.Phonon::AbstractMediaStream.setStreamSize() needs to be called, and also PySide.phonon.Phonon::AbstractMediaStream.setStreamSeekable() (if the stream is seekable). A good place to do this work is in the constructor. A seekable stream must also reimplement PySide.phonon.Phonon::AbstractMediaStream.seekStream() .
We show two examples. The first writes data repeatedly until it receives the PySide.phonon.Phonon::AbstractMediaStream.enoughData() call, while the second only writes once and waits for a new PySide.phonon.Phonon::AbstractMediaStream.needData() call.
Example where data is written repeatedly.
<Code snippet "doc/src/snippets/code/doc_src_phonon-api.cpp:0" not found>Example where data is written once:
<Code snippet "doc/src/snippets/code/doc_src_phonon-api.cpp:1" not found>See also
Phonon.MediaSource Phonon.MediaObject
Parameters: | parent – PySide.QtCore.QObject |
---|
Constructs an AbstractMediaStream object with the given parent .
Tells the backend that the media data stream is at its end.
Warning
Don’t call this function before the first PySide.phonon.Phonon::AbstractMediaStream.needData() is emitted.
See also
PySide.phonon.Phonon::AbstractMediaStream.writeData() PySide.phonon.Phonon::AbstractMediaStream.needData()
If your stream is a push stream, reimplement this function to be notified when the backend has enough data and your stream object may take a break.
This method is important for pushing data to the backend in order to not fill the backend buffer unnecessarily.
See also
PySide.phonon.Phonon::AbstractMediaStream.needData()
Parameters: |
|
---|
Reimplement this function to be notified when the backend needs data.
When this function is called you should write data to the backend (See PySide.phonon.Phonon::AbstractMediaStream.writeData() ).
See also
PySide.phonon.Phonon::AbstractMediaStream.writeData() PySide.phonon.Phonon::AbstractMediaStream.endOfData() PySide.phonon.Phonon::AbstractMediaStream.enoughData()
Reimplement this function to reset the stream. Subsequent calls to writeData should start from the first position of the data unless a seek is requested.
The function is necessary for the case where a non-seekable MediaStream is played more than once. For a seekable stream the implementation can simply call
<Code snippet "doc/src/snippets/code/doc_src_phonon-api.cpp:2" not found>
See also
PySide.phonon.Phonon::AbstractMediaStream.writeData() PySide.phonon.Phonon::AbstractMediaStream.needData()
Parameters: | offset – PySide.QtCore.qint64 |
---|
Reimplement this function if your stream is seekable.
When this function is called the next call to writeData has to be at the requested offset .
Warning
Do not call the parent implementation.
See also
PySide.phonon.Phonon::AbstractMediaStream.setStreamSeekable() PySide.phonon.Phonon::AbstractMediaStream.streamSeekable() PySide.phonon.Phonon::AbstractMediaStream.needData()
Parameters: | arg__1 – PySide.QtCore.bool |
---|
Sets whether your data stream is seekable. s should be true if the stream is seekable; otherwise false.
Defaults to false .
If you set this to true you have to implement the PySide.phonon.Phonon::AbstractMediaStream.seekStream() function.
See also
PySide.phonon.Phonon::AbstractMediaStream.streamSeekable()
Parameters: | arg__1 – PySide.QtCore.qint64 |
---|
Sets the size of the stream in number of bytes.
A negative value means that the length of the stream cannot be known.
Defaults to 0.
This function has to be called. A backend will not call PySide.phonon.Phonon::AbstractMediaStream.needData() until the stream size is set.
See also
PySide.phonon.Phonon::AbstractMediaStream.streamSize()
Return type: | PySide.QtCore.bool |
---|
Returns whether your data stream is set as seekable.
Defaults to false .
See also
PySide.phonon.Phonon::AbstractMediaStream.setStreamSeekable()
Return type: | PySide.QtCore.qint64 |
---|
Returns the stream size that was set with PySide.phonon.Phonon::AbstractMediaStream.setStreamSize() .
A negative value means that the length of the stream cannot be known.
Defaults to 0.
See also
PySide.phonon.Phonon::AbstractMediaStream.setStreamSize()
Parameters: | data – PySide.QtCore.QByteArray |
---|
Sends the media data to the backend for decoding.
Use this function to send data to the backend after PySide.phonon.Phonon::AbstractMediaStream.needData() has been called.
If your stream is a push stream, data should be written until the PySide.phonon.Phonon::AbstractMediaStream.enoughData() function is called. For a pull stream, write data once before the call to PySide.phonon.Phonon::AbstractMediaStream.needData() function returns.
If the data is depleted, call PySide.phonon.Phonon::AbstractMediaStream.endOfData() instead of PySide.phonon.Phonon::AbstractMediaStream.writeData() .
Warning
Don’t call this function before the first PySide.phonon.Phonon::AbstractMediaStream.needData() is emitted.
See also
PySide.phonon.Phonon::AbstractMediaStream.needData() PySide.phonon.Phonon::AbstractMediaStream.endOfData()