Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Phonon minimum needs to play a video: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Sub-categorize)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
='''Phonon''' minimum needs to play a video.=
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}


The [http://doc.qt.nokia.com/4.7/phonon-overview.html#phonon-overview documentation about Phonon] ''[doc.qt.nokia.com]'' provided by Qt doesn’t give you an “out of the box” explanation on how to play a video using Phonon in Qt. That’s why I write this down in order to help a little.
[[Category:Snippets::Misc]]


Before you start testing, make sure that you have the right programs and or libs installed on your computer. Look [http://doc.qt.nokia.com/4.7/phonon-overview.html#installing-phonon here] ''[doc.qt.nokia.com]'' for the setup you need.
= '''Phonon''' minimum needs to play a video. =
 
The [http://doc.qt.nokia.com/4.7/phonon-overview.html#phonon-overview documentation about Phonon] provided by Qt doesn't give you an "out of the box" explanation on how to play a video using Phonon in Qt. That's why I write this down in order to help a little.
 
Before you start testing, make sure that you have the right programs and or libs installed on your computer. Look [http://doc.qt.nokia.com/4.7/phonon-overview.html#installing-phonon here] for the setup you need.


You need only 4 items to get a video to play.
You need only 4 items to get a video to play.
# You need to have a [http://doc.qt.nokia.com/4.7/phonon-mediaobject.html Phonon::MediaObject]
# You need to have a [http://doc.qt.nokia.com/4.7/phonon-videowidget.html Phonon::VideoWidget]
# You need to have a [http://doc.qt.nokia.com/4.7/phonon-audiooutput.html Phonon::AudioOutput]
# add your .pro file with "+= phonon"
Then the code:


# You need to have a [http://doc.qt.nokia.com/4.7/phonon-mediaobject.html Phonon::MediaObject] ''[doc.qt.nokia.com]''
<code>
# You need to have a [http://doc.qt.nokia.com/4.7/phonon-videowidget.html Phonon::VideoWidget] ''[doc.qt.nokia.com]''
//include the right lib:
# You need to have a [http://doc.qt.nokia.com/4.7/phonon-audiooutput.html Phonon::AudioOutput] ''[doc.qt.nokia.com]''
#include <phonon>
# add your .pro file with “+= phonon”


Then the code:
// setup the objects:
Phonon::MediaObject *obj_MediaObject = new Phonon::MediaObject(this);
Phonon::VideoWidget *wid_videoWidget = new Phonon::VideoWidget(this);
Phonon::AudioOutput '''aio_audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory,this);
 
//clear the mediaobject:
obj_MediaObject->clearQueue();
 
//Put a video in the queue:
obj_MediaObject->enqueue(Phonon::MediaSource("path to video"));


That’s all there is.
//make the proper connections:
Phonon::createPath(obj_MediaObject, wid_videoWidget); // to link the mediaobject with the video widget.
Phonon::createPath(obj_MediaObject, aio_audioOutput); // to link the mediaobject with audio output.


* '''Note:''' This code only works on local video files. I didn’t have YouTube videos and mms streaming working yet. When I do, I will edit this page.
//play the video:
obj_MediaObject->play();
</code>


It’s off course also possible for others to edit a working code.
That's all there is.


===Categories:===
''' '''Note:''' This code only works on local video files. I didn't have YouTube videos and mms streaming working yet. When I do, I will edit this page.


* [[:Category:snippets|snippets]]
It's off course also possible for others to edit a working code.

Latest revision as of 12:04, 28 November 2016

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

Phonon minimum needs to play a video.

The documentation about Phonon provided by Qt doesn't give you an "out of the box" explanation on how to play a video using Phonon in Qt. That's why I write this down in order to help a little.

Before you start testing, make sure that you have the right programs and or libs installed on your computer. Look here for the setup you need.

You need only 4 items to get a video to play.

  1. You need to have a Phonon::MediaObject
  2. You need to have a Phonon::VideoWidget
  3. You need to have a Phonon::AudioOutput
  4. add your .pro file with "+= phonon"

Then the code:

//include the right lib:
#include <phonon>

// setup the objects:
Phonon::MediaObject *obj_MediaObject = new Phonon::MediaObject(this);
Phonon::VideoWidget *wid_videoWidget = new Phonon::VideoWidget(this);
Phonon::AudioOutput '''aio_audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory,this);

//clear the mediaobject:
obj_MediaObject->clearQueue();

//Put a video in the queue:
obj_MediaObject->enqueue(Phonon::MediaSource("path to video"));

//make the proper connections:
Phonon::createPath(obj_MediaObject, wid_videoWidget); // to link the mediaobject with the video widget.
Phonon::createPath(obj_MediaObject, aio_audioOutput); // to link the mediaobject with audio output.

//play the video:
obj_MediaObject->play();

That's all there is.

Note: This code only works on local video files. I didn't have YouTube videos and mms streaming working yet. When I do, I will edit this page.

It's off course also possible for others to edit a working code.