Note that there are some explanatory texts on larger screens.

plurals
  1. POHow could I add a Rectangle in my phonon media player?
    text
    copied!<p>Now This is a simple media player which is based on phonon(QT).</p> <pre><code>#include &lt;QApplication&gt; #include &lt;QWidget&gt; #include &lt;phonon&gt; #include &lt;QUrl&gt; #include &lt;QObject&gt; #include &lt;QVBoxLayout&gt; #include &lt;QHBoxLayout&gt; #include &lt;QLabel&gt; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *widget = new QWidget; widget-&gt;setWindowTitle("Media Player"); widget-&gt;resize(400,400); Phonon::MediaObject *media = new Phonon::MediaObject; media-&gt;setCurrentSource(Phonon::MediaSource("test.mpg")); Phonon::VideoWidget *vwidget = new Phonon::VideoWidget(widget); Phonon::createPath(media, vwidget); vwidget-&gt;setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); Phonon::AudioOutput *aOutput = new Phonon::AudioOutput(Phonon::VideoCategory); Phonon::createPath(media, aOutput); QLabel *label = new QLabel("Volume: "); Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider; volumeSlider-&gt;setAudioOutput(aOutput); volumeSlider-&gt;setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider; seekSlider-&gt;setMediaObject(media); QHBoxLayout *hLayout = new QHBoxLayout; hLayout-&gt;addWidget(label); hLayout-&gt;addWidget(volumeSlider); hLayout-&gt;addStretch(); QVBoxLayout *vLayout = new QVBoxLayout; vLayout-&gt;addWidget(vwidget); vLayout-&gt;addWidget(seekSlider); vLayout-&gt;addLayout(hLayout); widget-&gt;setLayout(vLayout); widget-&gt;show(); media-&gt;play(); return app.exec(); } </code></pre> <p>And now I want to add some sign in the current widget when it is playing video. How can I implement this? For example, if I want to add a rectangle in the specified position over the current frame. How could I do that?</p> <p>Now I have another try to do this: I define a class named MyVideoWidget which is inhred from Phonon::VideoWidget. Just like this:</p> <pre><code>class MyVideoWidget : public Phonon::VideoWidget </code></pre> <p>And then I overload the function paintEvent like this:</p> <pre><code>void MyVideoWidget::paintEvent (QPaintEvent * event) { Phonon::VideoWidget::paintEvent (event); QPainter painter (this); QPen pen; pen.setJoinStyle(Qt::MiterJoin); pen.setWidth(5); pen.setColor(QColor::fromRgb(255,255, 255)); painter.setPen(pen); painter.drawLine (QPoint (20, 20), QPoint (100, 20)); painter.drawLine (QPoint (20, 100), QPoint (100, 100)); } </code></pre> <p>But is still cannot work... Does anyone has some good idea?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload