Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Exception thrown when using Phonon::VideoWidget / Phonon::MediaObject
Qt 6.11 is out! See what's new in the release blog

Exception thrown when using Phonon::VideoWidget / Phonon::MediaObject

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    astorije
    wrote on last edited by
    #1

    I am trying to use the Phonon::VideoWidget and the Phonon::MediaObject together, as it is suggested in the documentation ("http://doc.qt.nokia.com/4.7/phonon-videowidget.html#details":http://doc.qt.nokia.com/4.7/phonon-videowidget.html#details).
    Basically, when using a Phonon::VideoPlayer component, everything works fine, but when using those 2 components, an unhandled exception is thrown when closing the window.

    It seems like the destruction of the Phonon::Path between the 2 objects crashes.
    When I checked in the Phonon::VideoPlayer source code, I did not see anything magic, and I am actually wondering if the Phonon::VideoPlayer class does not contain the same kind of trouble that we could not see because the encapsulated objects would not be properly destroyed before the application closes.

    As I am not sure to be totally clear or exhaustive, a code snippet is worth a thousand words:

    Test.h
    @#ifndef TEST_H_
    #define TEST_H_

    #include <QGraphicsProxyWidget>
    #include <Phonon/VideoPlayer>
    #include <Phonon/MediaObject>
    #include <Phonon/VideoWidget>

    class Test : public QGraphicsProxyWidget
    {
    Q_OBJECT

    public:
    Test(QGraphicsItem *parent = 0)
    : QGraphicsProxyWidget(parent)
    {
    // --------------
    // Works properly
    Phonon::VideoPlayer *player = new Phonon::VideoPlayer();
    player->mediaObject()->setCurrentSource(Phonon::MediaSource("trailer_400p.ogg"));
    player->mediaObject()->play();
    setWidget(player);
    // --------------

        // --------------------
        // Crashes when closing
        Phonon::MediaObject *media = new Phonon::MediaObject();
        Phonon::VideoWidget *vwidget = new Phonon::VideoWidget();
        Phonon::createPath(media, vwidget);
        media->setCurrentSource(Phonon::MediaSource("trailer_400p.ogg"));
        media->play();
        setWidget(vwidget);
        // --------------------
    }
    

    };

    #endif /* TEST_H_ */@

    main.cpp
    @#include <QApplication>
    #include <QGraphicsScene>
    #include <QGraphicsView>

    #include "Test.h"

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);

    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *gv = new QGraphicsView();
    gv->setScene(scene);
    
    Test *test = new Test();
    scene->addItem(test);
    test->resize(1280, 720);
    gv->show();
    
    return app.exec();
    

    }@

    Oh, just to precise things:

    • I've tried many different versions of this code, deleting the pointers in the destructor, connecting the deleteLater() slot on the destroyed() signals of the dynamically created objects, ... nothing changed!
    • the class inherits QGraphicsProxyWidget in order to be used as a QML widget afterwards.

    Is there a bug in the Qt implementation of Phonon? Or did I miss something important?
    Can anybody help me solving this please...

    Thanks!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved