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

How to play video backwards in qt using vlc-qt libvlc



  • I am developing a media player using vlc-qt , Actually I want a button which will play do the fast backward operation. I don't have the problem with the fast forward operation but not able to implement the fast backward operation, Is there any function there in vlc-qt which will play the video backwards. Here are the buttons code which I am using for fast forward and fast backward operation

    void expPlayer::on_pushButton_2_clicked()
    {
        m_player->setPlaybackRate(m_player->playbackRate()+1);
    }
    
    void expPlayer::on_pushButton_3_clicked()
    {
        //It should play the video backward with more playback rate.
    }
    

    Here is my full code
    my header file

    #ifndef EXPPLAYER_H
    #define EXPPLAYER_H
    
    #include <QMainWindow>
    #include "VLCQtCore/Instance.h"
    #include "VLCQtCore/MediaPlayer.h"
    #include "VLCQtCore/Media.h"
    #include "VLCQtCore/Common.h"
    #include "VLCQtCore/Config.h"
    #include "QPushButton"
    #include "QtMultimedia/QMediaPlaylist"
    #include "VLCQtWidgets/WidgetVideo.h"
    #include "VLCQtWidgets/WidgetSeekProgress.h"
    #include "QSlider"
    #include "QFileDialog"
    #include "QInputDialog"
    #include "QLabel"
    #include "QListView"
    #include "QBoxLayout"
    #include "VLCQtWidgets/WidgetSeek.h"
    QT_BEGIN_NAMESPACE
    namespace Ui { class expPlayer; }
    QT_END_NAMESPACE
    
    class expPlayer : public QMainWindow
    {
        Q_OBJECT
    
    public:
        expPlayer(QWidget *parent = nullptr);
        ~expPlayer();
    
    private slots:
        void on_pushButton_clicked();
    
        void on_pushButton_2_clicked();
        
        void on_pushButton_3_clicked();
        
    private:
        Ui::expPlayer *ui;
    
        VlcInstance *m_instance;
        VlcMedia *m_media;
        VlcMediaPlayer *m_player;
        VlcWidgetSeekProgress *m_progressBar;
    };
    #endif // EXPPLAYER_H
    
    
    

    My cpp file

    #include "expplayer.h"
    #include "ui_expplayer.h"
    
    expPlayer::expPlayer(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::expPlayer)
    {
        ui->setupUi(this);
        m_instance = new VlcInstance(VlcCommon::args(), this);
        m_player = new VlcMediaPlayer(m_instance);
    
        m_player->setVideoWidget(ui->m_video);
        ui->m_video->setMediaPlayer(m_player);
        m_progressBar=new VlcWidgetSeekProgress(this);
        m_progressBar->setMediaPlayer(m_player);
        ui->m_video->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
        ui->m_video->show();
    
        m_media = new VlcMedia("http://www.youtube.com/watch?v=Btv7G0BV45g",m_instance);
        m_player->open(m_media);
        qDebug()<<"m_player->video():"<<m_player->video();
        m_player->play();
    
        m_progressBar->resize(ui->m_video->width(),30);
        m_progressBar->move(ui->m_video->x(),ui->m_video->y()+ui->m_video->height()+20);
        m_progressBar->show();
    
    }
    
    expPlayer::~expPlayer()
    {
        delete ui;
    }
    
    
    void expPlayer::on_pushButton_clicked()
    {
    
    
    
    }
    
    void expPlayer::on_pushButton_2_clicked()
    {
        m_player->setPlaybackRate(m_player->playbackRate()+1);
    }
    
    void expPlayer::on_pushButton_3_clicked()
    {
        //It should play the video backward with more playback rate.
    }
    

Log in to reply