c++ - Phonon::MediaSource, cannot use resource as media source -
with qt 4.6, trying access wav file in qresource file use media source of media player , not work:
phonon::mediaobject *music; music=phonon::createplayer(phonon::musiccategory,phonon::mediasource(:/fps_sounds/arming.wav)); music->play();
if put direct path works. have been successful @ using resources in other parts of program there not seem problem there , qt doc says can use qresource type of operation. bug or missing something?
this 1 gave me scratch well. lo , behold, can implemented using temporary file:
{ qtemporaryfile f; f.open(); qresource res(":/badger"); f.write((char*)res.data(),res.size()); f.flush(); f.setautoremove(true); f.close(); qstring fn = f.filename(); qsound::play(fn); }
Comments
Post a Comment