KDE 4.7 PyKDE API Reference

- KDE's Python API

# MediaSource Class Reference

`from PyKDE4.phonon import *`

Namespace: Phonon

## Detailed Description

\class MediaSource mediasource.h phonon/MediaSource Note that all constructors of this class are implicit, so that you can simply write

     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);

Author:
  Matthias Kretz <kretz@kde.org>

## Enumerations
Type | { Invalid, LocalFile, Url, Disc, Stream, CaptureDevice, Empty }
## Methods
| __init__ (self)
| __init__ (self, QString fileName)
| __init__ (self, QUrl url)
| __init__ (self, Phonon.AbstractMediaStream stream)
| __init__ (self, QIODevice ioDevice)
| __init__ (self, Phonon.MediaSource rhs)
| __init__ (self, Phonon::ObjectDescription device)
| __init__ (self, Phonon::ObjectDescription device)
| __init__ (self, (QByteArray,QString) access)
| __init__ (self, DiscType discType, QString deviceName=QString())
| __init__ (self, Capture::DeviceType deviceType, CaptureCategory category=NoCaptureCategory)
Phonon::ObjectDescription | audioCaptureDevice (self)
bool | autoDelete (self)
[(QByteArray,QString)] | deviceAccessList (self)
QString | deviceName (self)
Phonon::DiscType | discType (self)
QString | fileName (self)
Phonon.Mrl | mrl (self)
bool | operator == (self, Phonon.MediaSource rhs)
| setAutoDelete (self, bool enable)
Phonon.AbstractMediaStream | stream (self)
Phonon.MediaSource.Type | type (self)
QUrl | url (self)
Phonon::ObjectDescription | videoCaptureDevice (self)

## Method Documentation

__init__ | ( |  | self ) |

Creates an empty MediaSource.

An empty MediaSource is considered valid and can be set on a MediaObject to unload its current media.

See also:
  Empty

__init__ | ( | self, |
|  | QString | fileName
| ) |  |  |

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

Parameters:

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

__init__ | ( | self, |
|  | QUrl | url
| ) |  |  |

Creates a MediaSource object for a URL.

Parameters:

  | url | URL to a media file or stream.

__init__ | ( | self, |
|  | Phonon.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.

Parameters:

  | stream | The AbstractMediaStream subclass to provide the media data.

See also:
  setAutoDelete

__init__ | ( | self, |
|  | QIODevice | ioDevice
| ) |  |  |

Creates a MediaSource object for a QIODevice.

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

Parameters:

  | 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

__init__ | ( | self, |
|  | Phonon.MediaSource | rhs
| ) |  |  |

Constructs a copy of rhs.

This constructor is fast thanks to explicit sharing.

__init__ | ( | self, |
|  | Phonon::ObjectDescription | device
| ) |  |  |

Creates a MediaSource object for video capture devices.

__init__ | ( | self, |
|  | Phonon::ObjectDescription | device
| ) |  |  |

Creates a MediaSource object for video capture devices.

__init__ | ( | self, |
|  | (QByteArray,QString) | access
| ) |  |  |

Creates a MediaSource object for a capture device, directly from the device access info.

Parameters:

  | access | How can the device be accessed (driver name - alsa, oss, etc.) and device name

__init__ | ( | self, |
|  | DiscType | discType,
|  | QString | deviceName=QString()
| ) |  |  |

Creates a MediaSource object for discs.

Parameters:

  | discType | See DiscType

Parameters:

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

__init__ | ( | self, |
|  | Capture::DeviceType | deviceType,
|  | CaptureCategory | category=NoCaptureCategory
| ) |  |  |

Sets the source to the preferred audio capture device for the specified category

Phonon::ObjectDescription audioCaptureDevice | ( |  | self ) |

Returns the audio capture device for the media source if applicable.

bool autoDelete | ( |  | self ) |

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

See also:
  setAutoDelete

[(QByteArray,QString)] deviceAccessList | ( |  | self ) |

Returns the access list for the device of this media source. Valid for capture devices.

QString deviceName | ( |  | self ) |

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

Phonon::DiscType discType | ( |  | self ) |

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

QString fileName | ( |  | self ) |

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

Phonon.Mrl mrl | ( |  | self ) |

Returns the MRL of the MediaSource if type() == URL or type() == LocalFile; otherwise returns Mrl(). Phonon.Mrl is based on QUrl and adds some additional functionality that is necessary to ensure proper encoding usage in the Phonon backends.

Usually you will not have to use this in an application.

Since:
  4.5

bool operator == | ( | self, |
|  | Phonon.MediaSource | rhs
| ) |  |  |

Returns true if this MediaSource is equal to rhs; otherwise returns false.

setAutoDelete | ( | self, |
|  | 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 yourself 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

Phonon.AbstractMediaStream stream | ( |  | self ) |

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

Phonon.MediaSource.Type type | ( |  | self ) |

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

See also:
  Type

QUrl url | ( |  | self ) |

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

Phonon::ObjectDescription videoCaptureDevice | ( |  | self ) |

Returns the video capture device for the media source if applicable.

## Enumeration Documentation

Type

Identifies the type of media described by the MediaSource object.

See also:
  MediaSource.type()

Enumerator:

  Invalid = -1 |
  LocalFile |
  Url |
  Disc |
  Stream |
  CaptureDevice |
  Empty |