# class MediaSource

###

Module | phonon
Namespace | Phonon
Class | MediaSource
Inherits |

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

### enums

- Type { Invalid, LocalFile, Url, Disc, Stream }

enum details

### methods

- MediaSource ( )

  returns ctor

  Creates an invalid MediaSource object.

  See also Invalid

- MediaSource (fileName)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  fileName | QString |

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

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  url | QUrl |

  Creates a MediaSource object for a URL.

  url - URL to a media file or stream.

- MediaSource (discType, deviceName)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  discType | Phonon.DiscType |
  deviceName | QString | 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 (stream)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  stream | Phonon.AbstractMediaStream |

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

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  ioDevice | QIODevice |

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

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  rhs | Phonon.MediaSource |

  Constructs a copy of rhs.

  This constructor is fast thanks to explicit sharing.

- MediaSource (a0)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  a0 | MediaSourcePrivate |

- autoDelete ( )

  returns bool

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

  See also setAutoDelete

- deviceName ( )

  returns QString

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

- discType ( )

  returns Phonon.DiscType

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

- fileName ( )

  returns QString

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

- operator == (rhs)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  rhs | Phonon.MediaSource |

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

- setAutoDelete (enable)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  enable | bool |

  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

- stream ( )

  returns Phonon.AbstractMediaStream

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

- type ( )

  returns Phonon::MediaSource.Type

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

  See also Type

- url ( )

  returns QUrl

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

### enums - detail

- Type { Invalid, LocalFile, Url, Disc, Stream }

  The MediaSource object does not describe any valid source.

  | Invalid | - -1 | - |
  | LocalFile | - | - |
  | Url | - | - |
  | Disc | - | - |
  | Stream | - | - |