Congratulations to our 2022 Qt Champions!

QAbstractVideoSurface for play video in qml

  • How to use QAbstractVideoSurface for play video in qml??
    After executing the file I get error in header file
    */ mymediaplayer.h
    public slots:

    void setVideoSurface(QAbstractVideoSurface surface);
    QAbstractVideoSurface getVideoSurface();

    error: cannot declare parameter 'surface' to be of abstract type 'QAbstractVideoSurface'
    void setVideoSurface(QAbstractVideoSurface surface);

    I get the error as above mentioned. ^

  • Lifetime Qt Champion


    First thing to do: you should pass a pointer to your QAbstractVideoSurface.

  • After clearing those errors,
    MyMediaPlayer* player = new MyMediaPlayer();
    QQuickView view;
    view.engine()->rootContext()->setContextProperty("mediaplayer", player);
    error: invalid use of incomplete type 'class QQmlEngine'
    forward declaration of class QQmlEngine

  • Lifetime Qt Champion

    You're missing the include of QQmlEngine.

  • got it thanks for the reply...

Log in to reply