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

解决方法

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...