PDA

View Full Version : Phonon::VideoPlayer



dano_labrosse
17th October 2009, 19:01
Hi

I'm new to Qt. I'm trying to get a Phonon::VideoPlayer running to playback an MPEG4 video. I have the VideoPlayer window displaying but the the video screen is just black and there is no video playback. I'm running this on Windows XP. My code is below, hope you can help.
thanks
Dano



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

//setup media object
//
media = new Phonon::MediaObject();
media->setCurrentSource(Phonon::MediaSource(QString("C:\\workspace\\sample_mpeg4.mp4")));

//setup player
//
videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory);
videoPlayer->setFixedSize(QSize(400,300));
videoPlayer->move(1280-400,0);
videoPlayer->show();
connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
videoPlayer->play(media->currentSource());

}

wysota
17th October 2009, 21:03
It's possible that your backend can't play the file. Are you able to play the move using Windows Media Player?

dano_labrosse
17th October 2009, 21:37
Hi wysota

Yes, it turns out Windows Media Player was unable to playback the file. WinXP DirectShow does not include support for MPEG-4 video by default. I installed 3ivx MPEG-4 (http://www.3ivx.com/) and the code works fine now.

I think Windows 7 DirectShow has support for MPEG-4 out of the box.

cheers!

cloaked_and_coastin
5th March 2010, 16:19
This may be a bit of a late reply, but:

Check the path that you have spelled out in the QString. You may not need the double backslashes(only a single backslash).

Also, be sure that you can play the video file with a different player to make sure you have the right codec loaded.

To get this code to work on a LINUX box, I used Qt Creator to create a new Qt4 Gui Application project (under options I included multimedia and phonon).

Then I copied and pasted your code into the mainwindow.cpp file and changed the path spelled out in the QString to a video file (a .mov file) in my directory structure.

I added the following into the mainwindow.h file:

#include <Phonon>

(above the MainWindow class declaration)
namespace Phonon {

class MediaObject;
class VideoPlayer;
}

(under the private: data members)
Phonon::MediaObject *media;
Phonon::VideoPlayer *videoPlayer;

I compiled, tried it and it worked fine except there were two different windows: a Mainwindow and a window
that played the video file and then disappeared. Other than that, it worked fine. Hope this helps.

cloaked_and_coastin
5th March 2010, 16:21
Opps. I didn't scroll down far enough to see that the problem was solved before my reply. Please disregard. Sorry.

sonu
20th January 2012, 10:10
I have same problem , I build a player in Win XP using Phonon::videoPlayer but when i am trying to play on window 7 , it show only black screen even no audio is playing .. can you suggest me? I m stuck here.. :confused:

MrShahi
1st February 2012, 06:33
Hi , you need to place phonon::backend plugin into your application directory. and restart your system, i hope it will work. cheers..