- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

# MediaSource Class Reference

Search for all occurrences

## Detailed Description

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>

Definition at line 61 of file mediasource.h.

`#include <Phonon/MediaSource>`

List of all members.

## Public Types
enum | Type { Invalid = -1, LocalFile, Url, Disc, Stream, Empty }
| Identifies the type of media described by the MediaSource object. More...
## Public Member Functions
| MediaSource ()
| Creates an empty MediaSource.
| MediaSource (const QString &fileName)
| Creates a MediaSource object for a local file or a Qt resource.
| MediaSource (const QUrl &url)
| Creates a MediaSource object for a URL.
| MediaSource (Phonon::DiscType discType, const QString &deviceName=QString())
| Creates a MediaSource object for discs.
| MediaSource (AbstractMediaStream *stream)
| Creates a MediaSource object for a data stream.
| MediaSource (QIODevice *ioDevice)
| Creates a MediaSource object for a QIODevice.
| ~MediaSource ()
| Creates a MediaSource object for capture devices.
| MediaSource (const MediaSource &rhs)
| Constructs a copy of `rhs`.
MediaSource & | operator= (const MediaSource &rhs)
| Assigns `rhs` to this MediaSource and returns a reference to this MediaSource.
bool | operator== (const MediaSource &rhs) const
| Returns `true` if this MediaSource is equal to `rhs`; otherwise returns `false`.
void | setAutoDelete (bool enable)
| Tell the MediaSource to take ownership of the AbstractMediaStream or QIODevice that was passed in the constructor.
bool | autoDelete () const
| Returns the setting of the auto-delete option.
Type | type () const
| Returns the type of the MediaSource (depends on the constructor that was used).
QString | fileName () const
| Returns the file name of the MediaSource if type() == LocalFile; otherwise returns QString().
QUrl | url () const
| Returns the url of the MediaSource if type() == URL or type() == LocalFile; otherwise returns QUrl().
Phonon::DiscType | discType () const
| Returns the disc type of the MediaSource if type() == Disc; otherwise returns NoDisc.
QString | deviceName () const
| Returns the device name of the MediaSource if type() == Disc; otherwise returns QString().
AbstractMediaStream * | stream () const
| Returns the media stream of the MediaSource if type() == Stream; otherwise returns 0.
## Protected Member Functions
| MediaSource (MediaSourcePrivate &)
## Protected Attributes
QExplicitlySharedDataPointer < MediaSourcePrivate > | d
## Friends
class | StreamInterface

## Member Enumeration Documentation

enum Type

Search for all occurrences

Identifies the type of media described by the MediaSource object.

See also:
  MediaSource::type()

Enumerator:

  Invalid | The MediaSource object does not describe any valid source. Search for all occurrences
  LocalFile | The MediaSource object describes a local file. Search for all occurrences
  Url | The MediaSource object describes a URL, which can be both a local file and a file on the network. Search for all occurrences
  Disc | The MediaSource object describes a disc. Search for all occurrences
  Stream | The MediaSource object describes a data stream. This is also the type used for QIODevices. See also: AbstractMediaStream Search for all occurrences
  Empty | An empty MediaSource. It can be used to unload the current media from a MediaObject. See also: MediaSource() Search for all occurrences

Definition at line 70 of file mediasource.h.

                      {
                Invalid = -1,
                LocalFile,
                Url,
                Disc,
                Stream,
                Empty
    /*          post 4.0:
                / **
                 * Links multiple MediaSource objects together.
                 * /
                Link
    */
            };

## Constructor & Destructor Documentation

MediaSource | ( |  | ) |

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

MediaSource | ( | const 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.

MediaSource | ( | const QUrl & | url | ) |

Creates a MediaSource object for a URL.

Parameters:

  url | URL to a media file or stream.

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

Creates a MediaSource object for discs.

Parameters:

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

MediaSource | ( | 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

~MediaSource | ( |  | ) |

Creates a MediaSource object for capture devices.

Destroys the MediaSource object.

MediaSource | ( | const MediaSource & | rhs | ) |

Constructs a copy of `rhs`.

This constructor is fast thanks to explicit sharing.

MediaSource | ( | MediaSourcePrivate & |  | ) | `[protected]`

## Member Function Documentation

MediaSource& operator= | ( | const MediaSource & | rhs | ) |

Assigns `rhs` to this MediaSource and returns a reference to this MediaSource.

This operation is fast thanks to explicit sharing.

bool operator== | ( | const MediaSource & | rhs | ) | const

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

void setAutoDelete | ( | bool | enable | ) |

Search for all occurrences

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

bool autoDelete | ( |  | ) | const

Search for all occurrences

Returns the setting of the auto-delete option.

The default is `false`.

See also:
  setAutoDelete

Type type | ( |  | ) | const

Search for all occurrences

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

See also:
  Type

QString fileName | ( |  | ) | const

Search for all occurrences

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

QUrl url | ( |  | ) | const

Search for all occurrences

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

Phonon::DiscType discType | ( |  | ) | const

Search for all occurrences

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

QString deviceName | ( |  | ) | const

Search for all occurrences

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

AbstractMediaStream* stream | ( |  | ) | const

Search for all occurrences

Returns the media stream of the MediaSource if type() == Stream; otherwise returns 0.

QIODevices are handled as streams, too.

## Friends And Related Function Documentation

friend class StreamInterface `[friend]`

Search for all occurrences

Definition at line 63 of file mediasource.h.

## Member Data Documentation

QExplicitlySharedDataPointer<MediaSourcePrivate> d `[protected]`

Search for all occurrences

Definition at line 270 of file mediasource.h.

The documentation for this class was generated from the following file:

- phonon/mediasource.h

MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource
MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource MediaSource