Qt调用VLC写的视频播放器源码

http://www.bcwhy.com/thread-18482-1-1.html


最近因为工作需要,做了个视频播放器,能播放目前绝大多数格式,也能播放流媒体文件,界面是用Qt做的,这个项目能在mac linux windows等平台编译运行,采用的是C++语言和C++的GUI库Qt调用开源项目VLC提供出来的SDK,VLC是一个开源的视频播放器,比较牛,没听过的朋友可以百度一下。
先上效果图:由于是工作上的项目,只能把之前研究VLC的代码开源出来,后面修改的商业项目就不共享了。
 

下载地址:(下载后打开vlc-qt\demo\demo-player\demo-player.pro即可编译,不过需要4.8.4版本的QtSdk)
千脑下载:vlc-qt.rar
百度网盘我已委托@夜影帮忙上传,待会不上!
百度网盘:http://pan.baidu.com/share/link?shareid=446507&uk=1714263552

部分代码:

#include
#include

#include
#include
#include
#include

#include "DemoPlayer.h"
#include "ui_DemoPlayer.h"

DemoPlayer::DemoPlayer(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::DemoPlayer),
      _media(0)
{
    ui->setupUi(this);

    _instance = new VlcInstance(VlcCommon::args(), this);
    _player = new VlcMediaPlayer(_instance);
    _player->setVideoWidget(ui->video);

    ui->video->setMediaPlayer(_player);
    ui->volume->setMediaPlayer(_player);
    ui->volume->setVolume(100);
    ui->seek->setMediaPlayer(_player);

    connect(ui->actionOpenLocal, SIGNAL(triggered()), this, SLOT(openLocal()));
    connect(ui->actionOpenUrl, SIGNAL(triggered()), this, SLOT(openUrl()));
    connect(ui->actionPause, SIGNAL(triggered()), _player, SLOT(pause()));
    connect(ui->actionStop, SIGNAL(triggered()), _player, SLOT(stop()));
    connect(ui->pause, SIGNAL(clicked()), _player, SLOT(pause()));
    connect(ui->stop, SIGNAL(clicked()), _player, SLOT(stop()));
}

DemoPlayer::~DemoPlayer()
{
    delete _player;
    delete _media;
    delete _instance;
    delete ui;
}

void DemoPlayer::openLocal()
{
    QString file =
            QFileDialog::getOpenFileName(this, tr("Open file"),
                                         QDir::homePath(),
                                         tr("Multimedia files(*)"));

    if (file.isEmpty())
        return;

    _media = new VlcMedia(file, true, _instance);

    _player->open(_media);
}

void DemoPlayer::openUrl()
{
    QString url =
            QInputDialog::getText(this, tr("Open Url"), tr("Enter the URL you want to play"));

    if (url.isEmpty())
        return;

    _media = new VlcMedia(url, _instance);

    _player->open(_media);
}


视频播放器源码,  VLC


你可能感兴趣的:(开源软件)