1 Star 0 Fork 0

cobrass/XiBerry

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
VideoPlayer.h 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
cobrass 提交于 2021-07-06 16:46 . t
#pragma once
#include <QObject>
#include <QString>
#include <QMutex>
#include <QWidget>
// 避免 ssize_t 引发的错误
#if defined(_MSC_VER)
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <vlc/vlc.h>
class VideoPlayer :public QObject
{
Q_OBJECT
public:
//播放状态
typedef enum state {
Idle,
Opening,
Buffering,
Playing,
Paused,
Stopped,
Ended,
Error
} State;
static VideoPlayer& getInstance();
static void release();
void setVideoWindow(QWidget* window);
VideoPlayer::State state();
friend void handleEvents(const libvlc_event_t* event, void* userData);
QString getTitle() const {
return titlestr;
}
int64_t getDur() const {
return dur;
}
int getSeek();
signals:
void durationChanged(qint64 dur);
void timeChanged(qint64 time);
void positionChanged(float pos);
void stateChanged(VideoPlayer::State state);
void xb_libvlc_wrong(QString msg);
public slots:
void openFile(const QString& file);
void setVolume(int vol);//设置音量
void seek(int pos);//跳播
void play();//播放
void pause();//暂停
void stop();//停止
private:
explicit VideoPlayer(QObject* parent = nullptr);
~VideoPlayer();
VideoPlayer(const VideoPlayer& other) = delete;
VideoPlayer& operator=(const VideoPlayer& other) = delete;
void attachEvents();//订阅事件
public:
QWidget* m_videoWindow = nullptr;
private:
QString titlestr;
int64_t dur;
libvlc_instance_t* m_instance = nullptr;
libvlc_media_player_t* m_player = nullptr;
libvlc_media_t* media = nullptr;
libvlc_event_manager_t* m_eventManager = nullptr;
VideoPlayer::State m_state = VideoPlayer::State::Idle;
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/cobrass/xiberry.git
git@gitee.com:cobrass/xiberry.git
cobrass
xiberry
XiBerry
master

搜索帮助