基于libVLC的视频播放器

下载地址http://download.videolan.org/pub/videolan/vlc/last/win64/

#include <stdio.h>
#include <tchar.h>
#include <time.h>
#include <windows.h>

#ifdef _WIN32
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
#include "vlc/vlc.h"
#pragma comment(lib, "libvlc.lib")
#pragma comment(lib, "libvlccore.lib")

int main(int argc, char* argv[])
{
    libvlc_instance_t* vlc_ins = NULL;
    libvlc_media_player_t* vlc_player = NULL;
    libvlc_media_t* vlc_media = NULL;

    //创建一个vlc实例
    vlc_ins = libvlc_new(0, NULL);

    if (vlc_ins != NULL)
    {
        libvlc_instance_t* inst;
        libvlc_media_player_t* mp;
        libvlc_media_t* m;
        libvlc_time_t length;
        int width;
        int height;
        int wait_time = 5000;
        //libvlc_time_t length;   
        /* Load the VLC engine */
        inst = libvlc_new(0, NULL);
        //Create a new item   
        //Method 1:   
       //m = libvlc_media_new_location (inst, "file:///F:\\movie\\cuc_ieschool.flv");   
      //Screen Capture   
        //m = libvlc_media_new_location (inst, "screen://");   
       //Method 2:   
        m = libvlc_media_new_path(inst, "E:\\1.mp4");

        /* Create a media player playing environement */
        mp = libvlc_media_player_new_from_media(m);


        /* No need to keep the media now */
        libvlc_media_release(m);

        // play the media_player   
        libvlc_media_player_play(mp);

        //wait until the tracks are created   
        Sleep(wait_time);
        length = libvlc_media_player_get_length(mp);
        width = libvlc_video_get_width(mp);
        height = libvlc_video_get_height(mp);
        printf("Stream Duration: %ds\n", length / 1000);
        printf("Resolution: %d x %d\n", width, height);
        //Let it play    
        Sleep(length - wait_time);

        // Stop playing   
        libvlc_media_player_stop(mp);

        // Free the media_player   
        libvlc_media_player_release(mp);

        libvlc_release(inst);

        return 0;
    }

}
未经允许不得转载:紫竹林-程序员中文网 » 基于libVLC的视频播放器
关于我们 免责申明 意见反馈 隐私政策
程序员中文网:公益在线网站,帮助学习者快速成长!
关注微信 技术交流
推荐文章
每天精选资源文章推送
推荐文章
随时随地碎片化学习
推荐文章
发现有趣的