免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2581 | 回复: 0
打印 上一主题 下一主题

Example of Using Libvlc [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-22 10:17 |只看该作者 |倒序浏览

                //test.c
#include
#include
#include
static void raise(libvlc_exception_t * ex)
{
    if (libvlc_exception_raised (ex))
    {
         fprintf (stderr, "error: %s\n", libvlc_exception_get_message(ex));
         exit (-1);
    }
}
int main(int argc, char* argv[])
{
    const char * const vlc_args[] = {
              "-I", "dummy", /* Don't use any interface */
              "--ignore-config", /* Don't use VLC's config */
              "--plugin-path=/set/your/path/to/libvlc/module/if/you/are/on/windows/or/macosx" };
    libvlc_exception_t ex;
    libvlc_instance_t * inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;
   
    libvlc_exception_init (&ex);
    /* init vlc modules, should be done only once */
    inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &ex);
    raise (&ex);

    /* Create a new item */
    m = libvlc_media_new (inst, "rtsp://127.0.0.1:8554/crazystone.ts", &ex);
    raise (&ex);
   
    /* XXX: demo art and meta information fetching */
   
    /* Create a media player playing environement */
    mp = libvlc_media_player_new_from_media (m, &ex);
    raise (&ex);
   
    /* No need to keep the media now */
    libvlc_media_release (m);
#if 0
    /* This is a non working code that show how to hooks into a window,
     * if we have a window around */
     libvlc_drawable_t drawable = xdrawable;
    /* or on windows */
     libvlc_drawable_t drawable = hwnd;
     libvlc_media_player_set_drawable (mp, drawable, &ex);
     raise (&ex);
#endif
    /* play the media_player */
    libvlc_media_player_play (mp, &ex);
    raise (&ex);
   
    sleep (10000000); /* Let it play a bit */
   
    /* Stop playing */
    libvlc_media_player_stop (mp, &ex);
    /* Free the media_player */
    libvlc_media_player_release (mp);
    libvlc_release (inst);
    raise (&ex);
    return 0;
}
cc test.c -lvlc -o test
./test


Reference:
1、
http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc.html
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93196/showart_2183672.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP