WidgetSeekProgress 不显示视频 Vlc-qt Qt 的媒体流逝和完整时间

WidgetSeekProgress not showing the media elapsed and full time of Video Vlc-qt Qt

我正在 Qt 中使用 vlc-qt 模块作为我的基础开发一个媒体播放器。所以我可以在 VlcWidgetVideo 中加载视频并使用 WidgetSeekProgress 显示视频的已用时间和完整时间。

问题是在创建视频并将其加载到小部件后,当我创建 WidgetSeekProgress 的对象时,它不显示视频的完整视频时间和经过的时间。它只显示左右两边没有时间的栏。 我的示例项目的代码如下 explayer.h

#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"

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();

private:
    Ui::expPlayer *ui;

    VlcInstance *m_instance;
    VlcMedia *m_media;
    VlcMediaPlayer *m_player;
    VlcWidgetSeekProgress *m_progressBar;
};
#endif // EXPPLAYER_H

explayer.cpp

#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);
    ui->m_video->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    ui->m_video->show();

    m_media = new VlcMedia("file:///home/vinay/Downloads/long_sample_video.mp4",m_instance);
    m_player->open(m_media);
    m_player->play();


}

expPlayer::~expPlayer()
{
    delete ui;
}


void expPlayer::on_pushButton_clicked()
{
    m_progressBar=new VlcWidgetSeekProgress(m_player,this);
    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();

}

我通过单击 UI 中的按钮创建了进度条实例,因为我认为视频没有按时加载。所以我的栏没有显示时间。

我只需要在媒体播放器实例化后将播放器添加到 WidgetSeekProgress 对象中。

m_instance = new VlcInstance(VlcCommon::args(), this);
    m_player = new VlcMediaPlayer(m_instance);
    ui->m_seek->setMediaPlayer(m_player);