[Qt-interest] Using phonon to play resources

Ian Clark mrrooster at gmail.com
Wed Jul 28 17:28:28 CEST 2010


Hi René,

On 27 July 2010 10:03, R. Reucher <rene.reucher at batcom-it.net> wrote:
> Ian Clark wrote:
>> Should it work like I expect, or is this way okay?
> Phonon::MediaSource doesn't allow to specify a resource directly (and
> contrary to your statement, I don't see where the documentation would imply
> this). So yes, your way of doing it now through a QFile (QIODevice *) seems
> correct to me.
>
I may be misunderstanding the documentation here, but the constructor
described in:

http://doc.trolltech.com/4.6.2/phonon-mediasource.html

says:

"MediaSource::MediaSource ( const QString & fileName )

Creates a MediaSource object for the file specified by fileName. You
can also use this constructor with Qt resources"

Although I've just noticed the examples in:

http://doc.trolltech.com/4.6.2/phonon-mediaobject.html

which just pass a resource style filename to 'setCurrentSource'.

>> If I do it this way do I need to ensure I delete the QFile explicitly?
> When you use the QFile::QFile(const QString &name, QObject *parent)
> constructor, the parent QObject should take care of it (at a later time,
> when the parent gets destroyed). Otherwise you will need to destroy the
> QFile instance explicitly, yes.
>
That's fine, TBH, unless the user changed sounds a lot I'm not tooo
worried about a single file object hanging around until exit, but to
be sure I'll change it to a class variable or similar.

[snip]

Thanks for the feedback. :)

Ian




More information about the Qt-interest-old mailing list