All pastes #2118159 Raw Edit

Something

public text v1 · immutable
#2118159 ·published 2012-02-11 22:28 UTC
rendered paste body
void RobertsUI::playVideo()
{
// Use the Qt GStreamer hack on systems with Qt Gstreamer phonon_backend
#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
    #define QT_GSTREAMER_HACK
#endif

    QWidget *container = new QWidget();

    // Create scene, and apply it to a view
    QGraphicsScene *scene = new QGraphicsScene(QRect(0,0,640,480));
    QGraphicsView *view = new QGraphicsView(scene, container);

#ifdef QT_GSTREAMER_HACK
    /**
     * ColorFilterProxy fixes the RGB gstreamer bug.  Later, we add the proxy
     * to the scene rather than the videoWidget itself.  Hack around the Qt
     * GStreamer bug.
     */
    GstreamerColorFilterProxyWidget *proxy = new GstreamerColorFilterProxyWidget();
    QWidget *w = new QWidget;
    Phonon::MediaObject *mediaObject = new Phonon::MediaObject(proxy);
    Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(w);
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(proxy);
#else
    Phonon::MediaObject *mediaObject = new Phonon::MediaObject(view);
    Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(0);
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory,this);
#endif /* QT_GSTREAMER_HACK */

    Phonon::createPath(mediaObject, videoWidget);
    Phonon::createPath(mediaObject, audioOutput);

#ifdef QT_GSTREAMER_HACK
    proxy->setWidget(w);
    scene->addItem(proxy);
#else
    scene->addWidget(videoWidget);
#endif /* QT_GSTREAMER_HACK */

    // Create Icons
    QSize iconSize = QSize(32,32);
    QString path = "data/images/kde-oxygen-icons/";
    QGraphicsPixmapItem *arrowLeftIcon = new QGraphicsPixmapItem(QIcon(path +
        "arrow-left.svgz").pixmap(iconSize,QIcon::Normal,QIcon::On),0);
    QGraphicsPixmapItem *arrowUpIcon = new QGraphicsPixmapItem(QIcon(path +
        "arrow-up.svgz").pixmap(iconSize,QIcon::Normal,QIcon::On),0);
    QGraphicsPixmapItem *arrowRightIcon = new QGraphicsPixmapItem(QIcon(path +
        "arrow-right.svgz").pixmap(iconSize,QIcon::Normal,QIcon::On),0);
    QGraphicsPixmapItem *arrowDownIcon = new QGraphicsPixmapItem(QIcon(path +
        "arrow-down.svgz").pixmap(iconSize,QIcon::Normal,QIcon::On),0);

    // Create video
    mediaObject->enqueue(Phonon::MediaSource("data/diving_mpeg2_mp2.mpg"));

    // Origin at top left, x is positive right, y is positive down
    arrowLeftIcon->setPos(0,240);
    arrowRightIcon->setPos(600,240);
    arrowUpIcon->setPos(320,0);
    arrowDownIcon->setPos(320,450);

    scene->addItem(arrowLeftIcon);
    scene->addItem(arrowUpIcon);
    scene->addItem(arrowRightIcon);
    scene->addItem(arrowDownIcon);

    setCentralWidget(container);
    view->show();
    mediaObject->play();
}