[Qt-interest] Using phonon to play resources

R. Reucher rene.reucher at batcom-it.net
Tue Jul 27 11:03:59 CEST 2010


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.

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

I'd suggest to prepare a single QFile instance and to use 
QFile::setFileName(QString &) prior to calling 
Phonon::MediaObject::setCurrentSource(QIODevice *). This way you'd need to 
take care of only one QFile instance, deleting it in a cleanup function or 
so (if it was created on the heap, that is)... there can only be one 
"current source" at a time anyway.

I haven't tried it this way, though.

HTH, René
-- 
René Reucher
rene.reucher at batcom-it.net
http://www.batcom-it.net/




More information about the Qt-interest-old mailing list