PDA

View Full Version : To Play Movie in QT 4



Isa
21st January 2008, 10:02
Hi,

I am looking for an option where I can embed a movie (small) with my widget and play whenever required. Pls. let me know if its possible.

Thanks in Advance

ashukla
21st January 2008, 10:31
Hi,

I am looking for an option where I can embed a movie (small) with my widget and play whenever required. Pls. let me know if its possible.

Thanks in Advance
Dear Isa!
You can use QX11EmbedContainer widget and play movie with the help of MPlayer application using with QProcess.

QProcess *mp=new QProcess(0);

connect(mp, SIGNAL(finished(int)),this,SLOT(endPlayProcess())) ;

QString program = "mplayer";
QStringList arguments;
QString windowId=QString::number(winId());
QString ratio="";
ratio+="-monitoraspect "+QString::number(4)+":"+QString::number(3)+" ";
arguments<<"-vo"<<"gl2" <<"-wid" << windowId << "-slave" <<mediaPath[currentIndex] << "n";
mp->start(program,arguments);

In Qt there is no Movie Player widget.

ashukla
21st January 2008, 10:34
Here mediaPath[currentIndex] means file Name with path which you want to play.

drake1983
9th June 2008, 03:17
I have a problem embedding mplayer inside Qt Widget, in kde works fine, but it doesn't work under gnome, the player doesn't show.



QProcess mplayerProcess = new QProcess;
QString program = "mplayer";
QStringList arguments;
arguments << finalVideo << "-wid"<<QString::number(previewBox->winId())<<"-nosound";
mplayerProcess->start(program,arguments);


previewBox is a GroupBox inside a QWidget.
Any help ?

aamer4yu
9th June 2008, 09:18
Have you seen Media Player example in Qt 4.4. It plays movie files using phonon :)

Brandybuck
10th June 2008, 18:52
Yes, use Phonon instead of XEmbed. It is included in Qt 4.4.0, and is meant for exactly this solution.

GuS
21st June 2008, 17:11
Hi!!

One question, Can i Play a video stream URL with Phonon?

Thanks!

Cheers.

wysota
21st June 2008, 21:25
Yes, Phonon-MediaSource takes a QUrl as its argument.

GuS
2nd August 2008, 11:56
Hi,

I did:



self.mediaObject = Phonon.MediaObject(self)
self.webcamUrl = QUrl("http://gdnet.com.ar:8081")
self.mediaObject.setCurrentSource(self.webcamUrl)


And it complains "MediaObject.setCurrentSource() has an invalid type"
I am using PyQt as well.
I saw in the example that sets the media source for url like that, so i Don't know which is the error :S
Even if I set an url to a ogg file, the same happens.

Any tip? Thanks.

Cheers.

EDIT: never mind, i was doing it wrong. Now i wrote:


self.mediaObject.setCurrentSource(Phonon.MediaSour ce(self.webcamUrl))