can't see a video play but only music in Qt
Hi,
I want to play a video in my application. But whenever I try to runt he application, I get the message "WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::VideoWidget ( no objectName )." And I can hear the music but not video. Here is my code
Code:
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
Phonon::VideoPlayer *player =
new Phonon::VideoPlayer(Phonon::VideoCategory, this);
player
->play
(QUrl("path"));
player->show();
}
#include <QMainWindow>
#include <phonon/VideoPlayer>
#include <phonon/backendcapabilities.h>
#include <QUrl>
#include <phonon>
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
I tried to run the code from http://www.qtcentre.org/threads/3048...w-black-screen but didn't work. Can any one please tell me what else should be required to play a video.
Thank You,
Baluk
Re: can't see a video play but only music in Qt
You have the correct decoder installed?
Re: can't see a video play but only music in Qt
I am sorry but what decoder I should use. I thought Qt takes the default one that is provided in my windows vista, isn't it so. I don't have much idea about decoder stuff I am trying to find it anyway.
Thank You,
Baluk
Re: can't see a video play but only music in Qt
Unless you have a codec capable of playing the video, all you'll get is audio.
We can't tell you which decoder to use as we don't know your file format.
Re: can't see a video play but only music in Qt
I want to play avi, mp3 and mkv format file.
Re: can't see a video play but only music in Qt
avi and mkv are only containers, what is the file type that you will be playing inside those containers? eg. xvid.
Re: can't see a video play but only music in Qt
oke. File type is VLC media file.
Re: can't see a video play but only music in Qt
No, it's not.
That's just the registered player you are using to play the file.
Re: can't see a video play but only music in Qt
Oke. Now I got to understand what is file format. I want to play avc1 and MPGV codec files.
Re: can't see a video play but only music in Qt
Re: can't see a video play but only music in Qt
I have it installed on my system. My audio was playing with this codec support only.
Re: can't see a video play but only music in Qt
Re: can't see a video play but only music in Qt
Quote:
Originally Posted by
hicham
So according to the link, I can't play a video using Qt 4.7. Is there any other way I could make it possible.
Re: can't see a video play but only music in Qt
I moved to Qt 4.6.2 and tried to run my application. But I still couldn't succeed. Here I am copying my code. Could any one please check If it is running on your system.
Code:
#include <QMainWindow>
#include <phonon/VideoPlayer>
#include <phonon/VideoWidget>
#include <phonon/backendcapabilities.h>
#include <QUrl>
#include <phonon>
namespace Ui {
class MainWindow;
}
Q_OBJECT
public:
~MainWindow();
protected:
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
//.CPP file
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug() << Phonon::BackendCapabilities::availableAudioOutputDevices();
Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(this);
Phonon::createPath(mediaObject, videoWidget);
Phonon::AudioOutput *audioOutput =
new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(mediaObject, audioOutput);
mediaObject
->setCurrentSource
(QUrl("file.mkv or .avi"));
connect(mediaObject, SIGNAL(finished()), mediaObject, SLOT(deleteLater()));
mediaObject->play();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow
::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
//.pro file
#-------------------------------------------------
#
# Project created by QtCreator 2010-10-10T23:15:17
#
#-------------------------------------------------
QT += opengl phonon multimedia
TARGET = video
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
wince*{
DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout
}
Thank You,
baluk
Re: can't see a video play but only music in Qt
Hi,
My problem is solved. Now I can play a video in my Qt app. It was solved when I enable the corresponding decoder in the ffdshow video decoder ( which is responsible for all format video play). Before I was overlooked the issue when running the application.
Re: can't see a video play but only music in Qt
Quote:
Originally Posted by
baluk
Hi,
My problem is solved. Now I can play a video in my Qt app. It was solved when I enable the corresponding decoder in the ffdshow video decoder ( which is responsible for all format video play). Before I was overlooked the issue when running the application.
Hi,
I am new to Qt and facing the same issue. I am using windows XP and also install k-Lite codec, but still not working, then I uninstalled that and installed FFDSHOW, do I need to configure anywhere in my system. Please suggest me.
Re: can't see a video play but only music in Qt
Did you open the ffdshow window and check the available video types and if they are enabled or disabled.
Re: can't see a video play but only music in Qt
I tried to play DIVX encoded .avi file. But it is not playing. I have also installed ffdshow and I have checked that DIVX XIDV codecs are enabled. Can somebody help me.
Re: can't see a video play but only music in Qt
Quote:
Originally Posted by
baluk
Hi,
My problem is solved. Now I can play a video in my Qt app. It was solved when I enable the corresponding decoder in the ffdshow video decoder ( which is responsible for all format video play). Before I was overlooked the issue when running the application.
Can you write, where and what did you do to see video?
Re: can't see a video play but only music in Qt
can anybody tell me in ffdshow video decoder what option shud i enable for playing .avi video file.I can only hear the music but no video........