PDA

View Full Version : The same question : Phonon how can i loop a video?



lucky
11th August 2011, 04:45
i find the same question here,but it not work in my qt;

so i now i have the same question:

one video how can loop?

this is my code :

mainwindow.h


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <phonon>
#include <QUrl>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

public slots:
void finishedone();

private:
Ui::MainWindow *ui;
Phonon::MediaObject *media;

};

#endif // MAINWINDOW_H


mainwindow.cpp


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

Phonon::MediaObject *media = new Phonon::MediaObject(this);
media->setCurrentSource(Phonon::MediaSource(QString("d:/1.mp3")));

Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(this->centralWidget());
Phonon::createPath(media, videoWidget);

Phonon::AudioOutput *ao = new Phonon::AudioOutput(Phonon::VideoCategory);
Phonon::createPath(media, ao);

media->play();
connect(media, SIGNAL(finished()), this, SLOT(finishedone()));

}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::finishedone()
{
media->play();
}


this code just play once? can i loop it ?

thanks ..

lucky
12th August 2011, 10:45
why nobody reply me ?

everyone thinks this problem is simple ?

come on baby, i need help !~

lucky
13th August 2011, 09:33
i have resolved this problem, whatever thanks in advanced!~