<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>Phonon.MediaSource Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">Phonon.MediaSource Class Reference<br /><sup><sup>[<a href="phonon.html">phonon</a> module]</sup></sup></h1><p>The MediaSource class provides multimedia data for media objects. <a href="#details">More...</a></p> <h3>Types</h3><ul><li><div class="fn" />enum <b><a href="phonon-mediasource.html#Type-enum">Type</a></b> { Invalid, LocalFile, Url, Disc, Stream, Empty }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="phonon-mediasource.html#MediaSource">__init__</a></b> (<i>self</i>, QString <i>fileName</i>)</li><li><div class="fn" /><b><a href="phonon-mediasource.html#MediaSource-2">__init__</a></b> (<i>self</i>, QUrl <i>url</i>)</li><li><div class="fn" /><b><a href="phonon-mediasource.html#MediaSource-3">__init__</a></b> (<i>self</i>, DiscType <i>discType</i>, QString <i>deviceName</i> = QString())</li><li><div class="fn" /><b><a href="phonon-mediasource.html#MediaSource-4">__init__</a></b> (<i>self</i>, QIODevice <i>ioDevice</i>)</li><li><div class="fn" /><b><a href="phonon-mediasource.html#MediaSource-5">__init__</a></b> (<i>self</i>, MediaSource <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="phonon-mediasource.html#autoDelete">autoDelete</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="phonon-mediasource.html#deviceName">deviceName</a></b> (<i>self</i>)</li><li><div class="fn" />DiscType <b><a href="phonon-mediasource.html#discType">discType</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="phonon-mediasource.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="phonon-mediasource.html#setAutoDelete">setAutoDelete</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" />Type <b><a href="phonon-mediasource.html#type">type</a></b> (<i>self</i>)</li><li><div class="fn" />QUrl <b><a href="phonon-mediasource.html#url">url</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="phonon-mediasource.html#__eq__">__eq__</a></b> (<i>self</i>, MediaSource <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="phonon-mediasource.html#__ne__">__ne__</a></b> (<i>self</i>, MediaSource <i>rhs</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The MediaSource class provides multimedia data for media objects.</p> <p>The MediaSource class manages a source of multimedia content, such as a music or video file, of which data is given to a <a href="phonon-mediaobject.html">MediaObject</a>.</p> <p>The media source knows how fetch its data from several sources, e.g., from files, a <a href="qiodevice.html">QIODevice</a>, or a CD. The possible source types are described by the <a href="phonon-mediasource.html#Type-enum">Type</a> 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 <a href="qiodevice.html">QIODevice</a>.</p> <p>The class has several functions to acquire information about the source it manages, e.g., <a href="phonon-mediasource.html#fileName">fileName</a>() and <a href="phonon-mediasource.html#url">url</a>(). The return from these functions are dependent on the <a href="phonon-mediasource.html#type">type</a>() of the media source.</p> <p>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 <a href="phonon-mediaobject.html">MediaObject</a>.</p> <pre class="cpp"> MediaObject m; <span class="type"><a href="qstring.html">QString</a></span> <a href="phonon-mediasource.html#fileName">fileName</a>(<span class="string">"/home/foo/bar.ogg"</span>); <span class="type"><a href="qurl.html">QUrl</a></span> <a href="phonon-mediasource.html#url">url</a>(<span class="string">"http://www.example.com/stream.mp3"</span>); <span class="type"><a href="qbuffer.html">QBuffer</a></span> <span class="operator">*</span>someBuffer; m<span class="operator">.</span>setCurrentSource(fileName); m<span class="operator">.</span>setCurrentSource(url); m<span class="operator">.</span>setCurrentSource(someBuffer); m<span class="operator">.</span>setCurrentSource(Phonon<span class="operator">.</span>Cd); </pre> <p>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.</p> <a id="qt-backends" name="qt-backends" /> <h3>Qt Backends</h3> <p>Currently, Qt's backends support files in local and remote locations. Support for other sources, such as CD/DVD, are planned for the future.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Type-enum" />MediaSource.Type</h3><p>Identifies the type of media described by the <a href="phonon-mediasource.html">MediaSource</a> object.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>Phonon.MediaSource.Invalid</tt></td> <td class="topAlign"><tt>-1</tt></td> <td class="topAlign">The <a href="phonon-mediasource.html">MediaSource</a> object does not describe any valid source.</td> </tr> <tr> <td class="topAlign"><tt>Phonon.MediaSource.LocalFile</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">The <a href="phonon-mediasource.html">MediaSource</a> object describes a local file.</td> </tr> <tr> <td class="topAlign"><tt>Phonon.MediaSource.Url</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">The <a href="phonon-mediasource.html">MediaSource</a> object describes an URL, which can be either a local file or a file on the network.</td> </tr> <tr> <td class="topAlign"><tt>Phonon.MediaSource.Disc</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">The <a href="phonon-mediasource.html">MediaSource</a> object describes a disc, e.g., a CD.</td> </tr> <tr> <td class="topAlign"><tt>Phonon.MediaSource.Stream</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">The <a href="phonon-mediasource.html">MediaSource</a> object describes a data stream. This is the type used for <a href="qiodevice.html">QIODevice</a>s. Note that a stream opened with a <a href="qurl.html">QUrl</a>, will still be of the Url type.</td> </tr> <tr> <td class="topAlign"><tt>Phonon.MediaSource.Empty</tt></td> <td class="topAlign"><tt>4</tt></td> <td class="topAlign">The media source doesn't have a source.</td> </tr> </table> <p><b>See also</b> <a href="phonon-mediasource.html#type">MediaSource.type</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="MediaSource" />MediaSource.__init__ (<i>self</i>, QString <i>fileName</i>)</h3><p>Creates a <a href="phonon-mediasource.html">MediaSource</a> object for the file specified by <i>fileName</i>. You can also use this constructor with <a href="resources.html">Qt resources</a></p> <h3 class="fn"><a name="MediaSource-2" />MediaSource.__init__ (<i>self</i>, <a href="qurl.html">QUrl</a> <i>url</i>)</h3><h3 class="fn"><a name="MediaSource-3" />MediaSource.__init__ (<i>self</i>, <a href="phonon.html#DiscType-enum">DiscType</a> <i>discType</i>, QString <i>deviceName</i> = QString())</h3><p>Creates a <a href="phonon-mediasource.html">MediaSource</a> object for a the URL specified by <i>url</i>.</p> <p>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.</p> <p><b>See also</b> <a href="qurl.html">QUrl</a>.</p> <h3 class="fn"><a name="MediaSource-4" />MediaSource.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>ioDevice</i>)</h3><p>Creates a <a href="phonon-mediasource.html">MediaSource</a> object for the type of disc specified by <i>discType</i> in the named device referred to by <i>deviceName</i>.</p> <p><b>Note:</b> <i>deviceName</i> is a platform dependent device name. It can be useful to specify this if the computer has more than one CD drive. On KDE, it is recommended to use the Solid hardware discovery framework to retrieve the device name in a portable way.</p> <h3 class="fn"><a name="MediaSource-5" />MediaSource.__init__ (<i>self</i>, <a href="phonon-mediasource.html">MediaSource</a> <i>rhs</i>)</h3><h3 class="fn"><a name="autoDelete" />bool MediaSource.autoDelete (<i>self</i>)</h3><p>Returns the setting of the auto-delete option. The default is false.</p> <p><b>See also</b> <a href="phonon-mediasource.html#setAutoDelete">setAutoDelete</a>().</p> <h3 class="fn"><a name="deviceName" />QString MediaSource.deviceName (<i>self</i>)</h3><p>Returns the device name of the <a href="phonon-mediasource.html">MediaSource</a> if <a href="phonon-mediasource.html#type">type</a>() == Disc; otherwise returns QString().</p> <p><b>See also</b> <a href="phonon-mediasource.html#type">type</a>().</p> <h3 class="fn"><a name="discType" /><a href="phonon.html#DiscType-enum">DiscType</a> MediaSource.discType (<i>self</i>)</h3><p>Returns the disc type of the <a href="phonon-mediasource.html">MediaSource</a> if <a href="phonon-mediasource.html#type">type</a>() == Disc; otherwise returns <a href="phonon.html#DiscType-enum">NoDisc</a>.</p> <p><b>See also</b> <a href="phonon-mediasource.html#type">type</a>().</p> <h3 class="fn"><a name="fileName" />QString MediaSource.fileName (<i>self</i>)</h3><p>Returns the file name of the <a href="phonon-mediasource.html">MediaSource</a> if <a href="phonon-mediasource.html#type">type</a>() == <a href="phonon-mediasource.html#Type-enum">LocalFile</a>; otherwise, returns QString().</p> <p><b>See also</b> <a href="phonon-mediasource.html#type">type</a>().</p> <h3 class="fn"><a name="setAutoDelete" />MediaSource.setAutoDelete (<i>self</i>, bool <i>enable</i>)</h3><p>If <i>enable</i> is true, the media source will take ownership of the object passed in the <a href="phonon-mediasource.html">MediaSource</a>'s constructor object that was passed in the constructor; otherwise, the programmer is responsible for deletion of this object.</p> <p>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.</p> <p><b>See also</b> <a href="phonon-mediasource.html#autoDelete">autoDelete</a>().</p> <h3 class="fn"><a name="type" /><a href="phonon-mediasource.html#Type-enum">Type</a> MediaSource.type (<i>self</i>)</h3><p>Returns the type of the <a href="phonon-mediasource.html">MediaSource</a> (depends on the constructor that was used).</p> <p><b>See also</b> <a href="phonon-mediasource.html#Type-enum">Type</a>.</p> <h3 class="fn"><a name="url" /><a href="qurl.html">QUrl</a> MediaSource.url (<i>self</i>)</h3><p>Returns the URL of the <a href="phonon-mediasource.html">MediaSource</a> if <a href="phonon-mediasource.html#type">type</a>() == URL or <a href="phonon-mediasource.html#type">type</a>() == <a href="phonon-mediasource.html#Type-enum">LocalFile</a>; otherwise returns <a href="porting4.html#qurl">QUrl</a>().</p> <p><b>See also</b> <a href="phonon-mediasource.html#type">type</a>().</p> <h3 class="fn"><a name="__eq__" />bool MediaSource.__eq__ (<i>self</i>, <a href="phonon-mediasource.html">MediaSource</a> <i>rhs</i>)</h3><h3 class="fn"><a name="__ne__" />bool MediaSource.__ne__ (<i>self</i>, <a href="phonon-mediasource.html">MediaSource</a> <i>rhs</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>