我试图在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
有人能指出这段代码中的错误吗?
答案 0 :(得分:0)
没有
它是否有效
libvlc_media_player_set_hwnd
和libvlc_media_player_set_xwindow
如果您不进行手动调用,Libvlc会自动生成一个窗口。这就是你如何弄清楚它是否是一个libvlc问题。
Bye Darian
答案 1 :(得分: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);