Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

    Hi,

    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);
    player->setMedia(QUrl::fromLocalFile("C:/Users/bharathiraja/Desktop/video.mp4"));
    player->play();
    @
    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