PDA

View Full Version : video fade in/out in phonon



panpanpandas
9th July 2009, 03:12
Hi all,

Is video fade in/out supported in phonon? Or anything that works when playing several videos?

Thanks!

umerlaton
31st July 2011, 04:27
//Hi! , dont know if it helps or its too late for posting..... I dont know if theres an easier way or if its already has an implemented function but... I did fade in and fade out"EFFECT" using Phonon::MediaObject brightness and contrast properties....
//SORRY FOR ENGLISH BUT I SPEAK SPANISH ... :D
//for example:

//CREATING THE VIDEOWIDGET
Phonon:;VideoWidget *widget = new Phonon::VideoWidget(this);
//"this" could be anything, thats just your parent so you choose...


//CREATING MEDIASOURCE
Phonon::MediaSource *media = new Phonon::MediaSource("your video path (you can actually use QFileDialog::getopenFileName to get a popup window to get the path of your file as it return a QString path if you ar using and QAPP)");

//CREATING MEDIAOBJECT
Phonon::MediaObject *mobj = new Phonon::MediaObject();
mobj->setCurrentSource(media);

//CREATING A PATH FOR THE VIDEO TO OUR WIDGET AND PLAYING IT

Phonon::CreatePath(mobj,widget);
mobj->play();

//NO WE CAN PLAY AROUND WITH THE BRIGHTNESS AND CONTRASTS VALUES OF THE MEDIA OBJECT, if u got a slider on your app for that specific video u can use the signal onValueChanged() and connect it to a slot function that modifies your brightness and contrast values
//SO YOU CHOOSE HOW TO MODIFY THE VALUES ,QTIMER,QPROPERTANIMATION.....
//BUT WHEN MODIFYING VALUES FOF BRIGHTNESS AND CONTRAST OF THE MEDIAOBJECT YOU NEED TO USE NEGATIVE VALUES! IN ORDER TO CREATE THE "FADE EFFECT"

//for example:
int myvalue = 50;//you can modify this value with a function yourself

mobj->setContrast(myvalue/100.0) //it needs a qreal level which is the same as a double value
mobj->setBrightness(myvalue/100.0) //THIS BOTH ARE NOT GOING TO WORK FOR OUR PURPOSES

/you must do it with negatives....
mobj->setContrast((myvalue-100,0)/100.0) //it need a qreal level which is the same as a double value
mobj->setBrightness((myvalue-100.0)/100.0) //OHH and im dividing by 100.0 cause the qreal level is from 0 to 1.0 not 0 to 100.0

//OHH REMEMBER THIS WILL ONLY OUT VIDEO NOT AUDIO.... YOU MUST USE Phonon::AudiOutput in order to play audio since we are using VideoWidget not VideoPlayer...
//THIS WAY YOU CAN GET A FADE EFFECT USING PHONON... HOPES IT HELPS IN SOMEWAY ...

Decessus
31st July 2011, 08:40
A slightly more resource minded approach could be handled by overlaying a QLabel over the widget and fading that in/out between videos. I could be wrong, but it might be lighter on resources than playing a video with effects.