为什么VLC使WinForm事件不起作用? [英] Why VLC make the event of WinForm not work?
本文介绍了为什么VLC使WinForm事件不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用C#设计WinForm。我想玩媒体,所以我使用了VLC。我通过P / invoke调用它。
起初,一切都是正确的。但在我播放电影一段时间后。所有活动都不起作用,包括关闭窗口的按钮。
这是代码
I designd a WinForm, using C#. I want play a media, so I used VLC. I invoked it by P/invoke.
At first, all are right. But after I play a movie for a while. All event didn't work, include the butten for closing window.
Here is the code
#include "stdafx.h"
#include "MagicPlayer.h"
#include <vlc\vlc.h>
libvlc_instance_t *inst = 0;
libvlc_media_t *m = 0;
libvlc_media_player_t *mp = 0;
libvlc_time_t movie_time = 0;
int VLC_load(void *handle)
{
inst = libvlc_new(0, NULL); /* Load the VLC engine */
if (inst == NULL)
return 1;
mp = libvlc_media_player_new(inst);
libvlc_media_player_set_hwnd(mp, handle); /* Make the video played in the window */
return 0;
}
int VLC_pause()
{
if (inst == NULL)
return 1;
if (mp == 0)
return 1;
if (m == 0)
return 1;
if (libvlc_media_player_get_state(mp) == libvlc_Playing)
{
movie_time = libvlc_media_player_get_time(mp);
libvlc_media_player_pause(mp);
return 0;
}
else if (libvlc_media_player_get_state(mp) == libvlc_Paused)
{
libvlc_media_player_pause(mp);
return 0;
}
return 0;
}
int VLC_play(char *file_name)
{
if (inst == NULL)
return 1;
if (mp == NULL)
return 1;
m = libvlc_media_new_path(inst, file_name);
libvlc_media_player_set_media(mp, m);
if (m == NULL)
return 2;
return libvlc_media_player_play(mp);
}
int VLC_go_back_to_last_stop()
{
if (mp == NULL)
return 1;
if (libvlc_media_player_get_state(mp) == libvlc_Playing){
libvlc_media_player_pause(mp);
libvlc_media_player_set_time(mp, movie_time);
return 0;
}
return 0;
}
int VLC_release()
{
if (mp != 0)
libvlc_media_player_release(mp);
if (m != 0)
libvlc_media_release(m);
if (inst != 0)
libvlc_release(inst);
return 0;
}
推荐答案
观看此视频:
https://www.youtube.com/watch?v=aAdKP79jT6o [ ^ ]
这篇关于为什么VLC使WinForm事件不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文