VLC学习 第一篇安装环境

一.从官网下载VLC
二.将里面的SDK 放到qt工程目录下
1.VLC_QT配置 
一.从官网下载VLC
二.将里面的SDK 放到qt工程目录下
三.将plugins libvlc.dl, libvlccore.dll放到debug

四.在qt.pro中添加库
LIBS += E:\qt\intel_cup\testVLC\testVLC\lib\libvlc.lib
LIBS += E:\qt\intel_cup\testVLC\testVLC\lib\libvlccore.lib
 
     
INCLUDEPATH += E:\qt\intel_cup\testVLC\testVLC\include
 
     
五.
 
     
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
 
     
    this->m_vlcMedia =NULL;
    this->m_vlcMplay = NULL;
    currentWId = ui->widget->winId();
    const char*vlc_args[] ={"-I","dummy","--ignore-config","--extraintf=logger","--verbose=2",};
     m_vlcInst = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]),vlc_args );
    // m_vlcInst = libvlc_new(sizeof(m_vlcArgs)/sizeof(m_vlcArgs[0]),m_vlcArgs);
}
 
     
MainWindow::~MainWindow()
{
 
     
    delete ui;
    
}
 
     
void MainWindow::on_startButton_clicked()
{
 // const char*vlc_args[] ={"-I","dummy","--ignore-config","--extraintf=logger","--verbose=2",};
 
     
 //  m_vlcInst = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]),vlc_args );
    m_vlcMedia = libvlc_media_new_location(m_vlcInst,ui->UrlEdit->text().toLatin1());
    m_vlcMplay = libvlc_media_player_new_from_media(m_vlcMedia);
   // libvlc_media_player_set_drawable(m_vlcMplay, (libvlc_drawable_t)currentWId);
    libvlc_media_player_set_hwnd(m_vlcMplay,(void*)&currentWId);
    //播放
    libvlc_media_player_play(m_vlcMplay);
}
 
     
void MainWindow::on_closeButton_clicked()
{
    if(!m_vlcInst)
    {
        libvlc_release(m_vlcInst);
    }
    if(!m_vlcMedia)
    {
        libvlc_media_release(m_vlcMedia);
    }
    if(!m_vlcMplay)
    {
        libvlc_media_player_stop(m_vlcMplay);
    }
}
 
     
void MainWindow::on_pushButton_clicked()
{
    QString fileOpen = QFileDialog::getOpenFileName(this,tr("Load a file"), "~");
    fileOpen.replace("/", "\\"); //因为getOpenFileName得到的文件名是类//似于C:/Hello/test.avi,与windows下的路径名不匹配,所以需要这一步转换
        /* Stop if something is playing */
    //if(&& libvlc_media_player_is_playing(vlcPlayer) )
 
     
    //  stop();
        /* New Media */
 
     
        m_vlcMedia = libvlc_media_new_path(m_vlcInst,fileOpen.toLatin1());
        if( !m_vlcMedia )
            return;
        m_vlcMplay = libvlc_media_player_new_from_media(m_vlcMedia);
        libvlc_media_release(m_vlcMedia);
        /* Integrate the video in the interface */
    #if defined(Q_OS_MAC)
        libvlc_media_player_set_nsobject(vlcPlayer, videoWidget->winId());
    #elif defined(Q_OS_UNIX)
        libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId());
    #elif defined(Q_OS_WIN)
        libvlc_media_player_set_hwnd(m_vlcMplay,(void*)&currentWId);
    #endif
        //int windid = videoWidget->winId();
        //libvlc_media_player_set_xwindow (vlcPlayer, windid );
          libvlc_media_player_set_xwindow();
        /* And play */
        libvlc_media_player_play(m_vlcMplay);
 
     
        //Set vars and text correctly
 
     
        //playBut->setText("Pause");
 
     
}
成功,既能访问本地,又能访问rtsp





三.将plugins libvlc.dl, libvlccore.dll放到debug

四.在qt.pro中添加库
LIBS += E:\qt\intel_cup\testVLC\testVLC\lib\libvlc.lib
LIBS += E:\qt\intel_cup\testVLC\testVLC\lib\libvlccore.lib
 
   
INCLUDEPATH += E:\qt\intel_cup\testVLC\testVLC\include
 
   
五.
 
   
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
 
   
    this->m_vlcMedia =NULL;
    this->m_vlcMplay = NULL;
    currentWId = ui->widget->winId();
    const char*vlc_args[] ={"-I","dummy","--ignore-config","--extraintf=logger","--verbose=2",};
     m_vlcInst = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]),vlc_args );
    // m_vlcInst = libvlc_new(sizeof(m_vlcArgs)/sizeof(m_vlcArgs[0]),m_vlcArgs);
}
 
   
MainWindow::~MainWindow()
{
 
   
    delete ui;
    
}
 
   
void MainWindow::on_startButton_clicked()
{
 // const char*vlc_args[] ={"-I","dummy","--ignore-config","--extraintf=logger","--verbose=2",};
 
   
 //  m_vlcInst = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]),vlc_args );
    m_vlcMedia = libvlc_media_new_location(m_vlcInst,ui->UrlEdit->text().toLatin1());
    m_vlcMplay = libvlc_media_player_new_from_media(m_vlcMedia);
   // libvlc_media_player_set_drawable(m_vlcMplay, (libvlc_drawable_t)currentWId);
    libvlc_media_player_set_hwnd(m_vlcMplay,(void*)&currentWId);
    //播放
    libvlc_media_player_play(m_vlcMplay);
}
 
   
void MainWindow::on_closeButton_clicked()
{
    if(!m_vlcInst)
    {
        libvlc_release(m_vlcInst);
    }
    if(!m_vlcMedia)
    {
        libvlc_media_release(m_vlcMedia);
    }
    if(!m_vlcMplay)
    {
        libvlc_media_player_stop(m_vlcMplay);
    }
}
 
   
void MainWindow::on_pushButton_clicked()
{
    QString fileOpen = QFileDialog::getOpenFileName(this,tr("Load a file"), "~");
    fileOpen.replace("/", "\\"); //因为getOpenFileName得到的文件名是类//似于C:/Hello/test.avi,与windows下的路径名不匹配,所以需要这一步转换
        /* Stop if something is playing */
    //if(&& libvlc_media_player_is_playing(vlcPlayer) )
 
   
    //  stop();
        /* New Media */
 
   
        m_vlcMedia = libvlc_media_new_path(m_vlcInst,fileOpen.toLatin1());
        if( !m_vlcMedia )
            return;
        m_vlcMplay = libvlc_media_player_new_from_media(m_vlcMedia);
        libvlc_media_release(m_vlcMedia);
        /* Integrate the video in the interface */
    #if defined(Q_OS_MAC)
        libvlc_media_player_set_nsobject(vlcPlayer, videoWidget->winId());
    #elif defined(Q_OS_UNIX)
        libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId());
    #elif defined(Q_OS_WIN)
        libvlc_media_player_set_hwnd(m_vlcMplay,(void*)&currentWId);
    #endif
        //int windid = videoWidget->winId();
        //libvlc_media_player_set_xwindow (vlcPlayer, windid );
          libvlc_media_player_set_xwindow();
        /* And play */
        libvlc_media_player_play(m_vlcMplay);
 
   
        //Set vars and text correctly
 
   
        //playBut->setText("Pause");
 
   
}
成功,既能访问本地,又能访问rtsp





三.将plugins libvlc.dl, libvlccore.dll放到debug

四.在qt.pro中添加库
LIBS += E:\qt\intel_cup\testVLC\testVLC\lib\libvlc.lib
LIBS += E:\qt\intel_cup\testVLC\testVLC\lib\libvlccore.lib
 
 
INCLUDEPATH += E:\qt\intel_cup\testVLC\testVLC\include
 
 
五.
 
 
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
 
 
    this->m_vlcMedia =NULL;
    this->m_vlcMplay = NULL;
    currentWId = ui->widget->winId();
    const char*vlc_args[] ={"-I","dummy","--ignore-config","--extraintf=logger","--verbose=2",};
     m_vlcInst = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]),vlc_args );
    // m_vlcInst = libvlc_new(sizeof(m_vlcArgs)/sizeof(m_vlcArgs[0]),m_vlcArgs);
}
 
 
MainWindow::~MainWindow()
{
 
 
    delete ui;
    
}
 
 
void MainWindow::on_startButton_clicked()
{
 // const char*vlc_args[] ={"-I","dummy","--ignore-config","--extraintf=logger","--verbose=2",};
 
 
 //  m_vlcInst = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]),vlc_args );
    m_vlcMedia = libvlc_media_new_location(m_vlcInst,ui->UrlEdit->text().toLatin1());
    m_vlcMplay = libvlc_media_player_new_from_media(m_vlcMedia);
   // libvlc_media_player_set_drawable(m_vlcMplay, (libvlc_drawable_t)currentWId);
    libvlc_media_player_set_hwnd(m_vlcMplay,(void*)&currentWId);
    //播放
    libvlc_media_player_play(m_vlcMplay);
}
 
 
void MainWindow::on_closeButton_clicked()
{
    if(!m_vlcInst)
    {
        libvlc_release(m_vlcInst);
    }
    if(!m_vlcMedia)
    {
        libvlc_media_release(m_vlcMedia);
    }
    if(!m_vlcMplay)
    {
        libvlc_media_player_stop(m_vlcMplay);
    }
}
 
 
void MainWindow::on_pushButton_clicked()
{
    QString fileOpen = QFileDialog::getOpenFileName(this,tr("Load a file"), "~");
    fileOpen.replace("/", "\\"); //因为getOpenFileName得到的文件名是类//似于C:/Hello/test.avi,与windows下的路径名不匹配,所以需要这一步转换
        /* Stop if something is playing */
    //if(&& libvlc_media_player_is_playing(vlcPlayer) )
 
 
    //  stop();
        /* New Media */
 
 
        m_vlcMedia = libvlc_media_new_path(m_vlcInst,fileOpen.toLatin1());
        if( !m_vlcMedia )
            return;
        m_vlcMplay = libvlc_media_player_new_from_media(m_vlcMedia);
        libvlc_media_release(m_vlcMedia);
        /* Integrate the video in the interface */
    #if defined(Q_OS_MAC)
        libvlc_media_player_set_nsobject(vlcPlayer, videoWidget->winId());
    #elif defined(Q_OS_UNIX)
        libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId());
    #elif defined(Q_OS_WIN)
        libvlc_media_player_set_hwnd(m_vlcMplay,(void*)&currentWId);
    #endif
        //int windid = videoWidget->winId();
        //libvlc_media_player_set_xwindow (vlcPlayer, windid );
          libvlc_media_player_set_xwindow();
        /* And play */
        libvlc_media_player_play(m_vlcMplay);
 
 
        //Set vars and text correctly
 
 
        //playBut->setText("Pause");
 
 
}
成功,既能访问本地,又能访问rtsp




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值