1

我正在尝试在 Windows 7 上使用 libvlc 在 Qt Widget 中播放。我需要一些由 libvlc 提供的功能,这些功能在声子中不存在。我正在使用以下代码:

_videoWidget = new QFrame(this);
qDebug()<<fileName;
const char * const vlc_args[] = {
    "-I qt4",
              "--extraintf=logger",
              "--verbose=2" };
 _vlcinstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
 _mp = libvlc_media_player_new (_vlcinstance);
 _m = libvlc_media_new_path(_vlcinstance, fileName.toAscii());
 libvlc_media_player_set_media (_mp, _m);
 libvlc_media_player_set_hwnd(_mp, 0);//(_videoWidget->winId());
 int windid = reinterpret_cast<int>(_videoWidget->winId());
 libvlc_media_player_set_xwindow (_mp, windid );
 libvlc_media_player_play (_mp);

在我选择播放文件后它什么也不做,没有帧没有调试输出?调试控制台操作是:

    [0ac8f670] main libvlc debug: VLC media player - 2.0.3 Twoflower
[0ac8f670] main libvlc debug: Copyright © 1996-2012 VLC authors and VideoLAN
[0ac8f670] main libvlc debug: revision 2.0.3-0-g77aa89e
[0ac8f670] main libvlc debug: configured with ../extras/package/win32/../../../configure  '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-twolame' '--enable-quicktime' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-dca' '--enable-mpc' '--enable-libass' '--enable-x264' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-dvdread' '--enable-shout' '--enable-goom' '--enable-caca' '--disable-portaudio' '--disable-sdl' '--enable-qt4' '--enable-skins2' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-sqlite' '--disable-dirac' '--host=i586-mingw32msvc' '--enable-crystalhd' 'host_alias=i586-mingw32msvc'
[0ac8f670] main libvlc debug: searching plug-in modules
[0ac8f670] main libvlc debug: loading plugins cache file E:\Work\Local_WorkingCopy\VidTest\plugins\plugins.dat
[0ac8f670] main libvlc debug: recursively browsing `E:\Work\Local_WorkingCopy\VidTest\plugins'
[0ac8f670] main libvlc debug: saving plugins cache E:\Work\Local_WorkingCopy\VidTest\plugins\plugins.dat
[0ac8f670] main libvlc debug: plug-ins loaded: 388 modules
[0ac8f670] main libvlc debug: translation test: code is "C"
[0ac8f670] main libvlc debug: CPU has capabilities MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 FPU 
[0ac8f670] main libvlc debug: looking for memcpy module: 4 candidates
[0ac8f670] main libvlc debug: using memcpy module "memcpymmxext"
[0c680ab8] main interface debug: looking for interface module: 1 candidate

有人可以指出这段代码中的错误吗?

4

2 回答 2

0

它在没有
libvlc_media_player_set_hwnd和的情况下工作吗libvlc_media_player_set_xwindow

如果您不进行手动调用,Libvlc 会自动生成一个窗口。这就是您如何确定它是否是 libvlc 问题。

再见达里安

于 2013-09-28T17:06:05.640 回答
0

这是我的代码示例,它工作正常:

const char *const vlc_args [] = {
        "--verbose=3"   //be much more verbose then normal for debugging purpose
        ,"--quiet"
    };

    instance         = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
    player           = libvlc_media_player_new (instance);
    ...

    libvlc_media_player_set_hwnd (player, reinterpret_cast<HWND> (winId));
    QByteArray temp  = url.toEncoded ();
    const char *path = temp.constData ();
    media            = libvlc_media_new_location (instance, path);
    libvlc_media_player_set_media (player, media);
    int res          = libvlc_media_player_play (player);
于 2013-09-29T00:51:06.467 回答