bossman
bossman

Reputation: 421

Qt Play the same video in five Phonon::VideoWidget

I'm trying to play the same video in five windows:

     Widget::Widget(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::Widget)
    {
        ui->setupUi(this);
         media = new Phonon::MediaObject(this);
        media->setCurrentSource(Phonon::MediaSource("video.flv"));

        Phonon::VideoWidget* fvid=new Phonon::VideoWidget(this);
        Phonon::createPath(media,fvid);
        fvid->setGeometry(20,20,122,122);
        fvid->show();

        Phonon::VideoWidget* fvid2=new Phonon::VideoWidget(this);
        Phonon::createPath(media,fvid2);
        fvid2->setGeometry(220,220,122,122);
        fvid2->show();
    }

void Widget::on_pushButton_clicked()
{
    media->play();
}

This code works for one VideoWidget, but not for two or five. If I create several Mediaobjects, my cpu usage goes up to 70-90%. The same task was solved in FLash for browsers. But I need solution for C++ Qt. I dont have any others ideas. The video.flv is 144x144 and its duration is about 7-8 seconds.

Upvotes: 0

Views: 1344

Answers (1)

karlphillip
karlphillip

Reputation: 93478

I don't know if Phonon supports frame grabbing, but a better idea is to have only one Phonon player, and then you would make a copy of each frame being renderended to a QImage object. You could then copy the QImage to another 4 QLabel objects, one for each of the 4 windows.

This solution uses a lot less CPU processing since you will be only rendering one video.

The truth is that Phonon is dying, and Qt Mobility offers QMediaPlayer/QVideoWidget which are simple to work with and allows frame grabbing. I suggest you move your application to this technology.

Upvotes: 0

Related Questions