WidgetSeekProgress不显示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中的一个按钮来创建进度条的实例,因为我认为视频不能按时加载。所以我的酒吧没有告诉我时间。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)