VLCTest.rar VLC-Qt:一个结合了 Qt 应用程序和 libVLC 的免费开源库。它包含了用于媒体播放的核心类,以及用于更快速地进行媒体播放器开发的一些 GUI 类。该例子简单示范了如何配置并使用VLC-Qt库。 VLC-Qt库:一个在libVLC基础上结合了Qt框架的开源库。它提供了媒体播放的视频、音频处理控制的核心类,并提供基于QWidget和QML的GUI框架。效果图: 下载编译好的库VLC-Qt_1.1.0_win32_mingw.7z,解压到本地磁盘中,我解压路径为 E:VLCVLC VLC-Qt 编译好的库下载地址:https://download.csdn.net/download/zjgo007/12461366 把解压后的bin目录下的dll库拷贝至Qt安装目录下的bin文件夹中 E:Qt5.11.25.11.2mingw53_32bin 新建工程,在.pro文件中添加VLC库文件(本文没有使用到QML,因此可以不用链接该库)。 在设计师界面中,拖拽QWdget将QWidget提升为VlcWidgetVideo 完整代码: 完整Demo地址:
main.cpp:
#include "widget.h" #include <QApplication> #include <VLCQtCore/Common.h> int main(int argc, char *argv[]) { QApplication a(argc, argv); VlcCommon::setPluginPath( "E:/VLC/VLC/bin/plugins");//添加插件所处路径 Widget w; w.show(); return a.exec(); }
widget.h:
#ifndef WIDGET_H #define WIDGET_H #include <QWidget> #include <VLCQtCore/Common.h> #include <VLCQtCore/Instance.h> #include <VLCQtCore/Media.h> #include <VLCQtCore/MediaPlayer.h> namespace Ui { class Widget; } class Widget : public QWidget { Q_OBJECT public: explicit Widget(QWidget *parent = nullptr); ~Widget(); private slots: void on_pushButton_start_clicked(); void on_pushButton_pause_clicked(bool checked); void on_pushButton_stop_clicked(); private: Ui::Widget *ui; VlcInstance *instance; VlcMedia *media; VlcMediaPlayer *player; }; #endif // WIDGET_H
widget.cpp
#include "widget.h" #include "ui_widget.h" #include <QInputDialog> Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); instance = new VlcInstance(VlcCommon::args(), this); player = new VlcMediaPlayer(instance); player->setVideoWidget(ui->VlcWidget); } Widget::~Widget() { delete ui; } void Widget::on_pushButton_start_clicked()//开始播放视频流 { QString url = QInputDialog::getText(this, tr("打开网络流"), tr("网络流地址")); if (!url.isEmpty()){ media = new VlcMedia(url, instance); player->open(media); } } void Widget::on_pushButton_pause_clicked(bool checked)//对视频流暂停及继续播放 { if(checked) ui->pushButton_pause->setText("继续"); else ui->pushButton_pause->setText("暂停"); player->togglePause(); } void Widget::on_pushButton_stop_clicked()//停止播放视频流 { player->stop(); }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算