锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 开源技术 / nVLC / 初始化和释放多个IPlayer对象的正确方法
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883

Proper way to initialize and dispose multiple IPlayer objects初始化和释放多个IPlayer对象的正确方法


Can you tell me if you have mdi based application, in which you are creating mdi forms which are on init creating IDiskPlayer objects and assigning WindowHandle from that object to some panel on the mdi form,what is proper way to dispose,stop etc.. those player object if you example close the mdi form,why im asking this is because when you load some file in player, then when you close the mdi form sometimes it gets stuck, and whole application because of that is not responding, it can be repeated if you create multiple mdi forms, load some video files, and close them all from main form like this, from what i could see main thread stops working on player.Stop() api call, don't know why,it's random, any help,pointers etc..如果开发mdi应用,应用里包含mdi窗体,窗体上要初始化创建IDiskPlayer对象和分配窗体上的WindowHandle到IDiskPlayer对象上,在处理释放停止等事务时,什么方法正确,请告诉我下。有下面情况困惑我,所以我才问,比如当你加载文件到播放对象时,当你关闭mdi窗体时,窗体会卡住,整个程序都没反应,如果你创建多个mdi窗体、加载一些视频文件且通过主窗体关闭这些子mdi窗体,这个问题会重复发生,据我所知主线程执行到player.Stop()时停止,不知道为什么,会随机产生,请提示下。

foreach (BaseStreamForm childForm in this.MdiChildren)
{
{
childForm.Close();
}
catch (Exception ex)
{
Trace.Write(ex.Message);
}
}
sample mdiform
public class StreamFormsData
{
private static IMediaPlayerFactory factory;
public static IMediaPlayerFactory GetPlayerFactory
{
get { return factory ?? (factory = new MediaPlayerFactory()); }
}
}
public partial class VLCPlayerForm : BaseStreamForm
{
private IDiskPlayer player;
private IMedia media;
public VLCPlayerForm()
{
InitializeComponent();
InitVLC();
}
private void InitVLC()
{
player = StreamData.GetPlayerFactory.CreatePlayer<IDiskPlayer>();
if (player != null)
player.WindowHandle = pictureBox1.Handle;
}
private void OpenFile(string file)
{
player.Stop();
media = StreamData.GetPlayerFactory.CreateMedia<IMedia>(file);
player.Open(media);
player.Play();
}
private void OnFormClosing(object sender, FormClosingEventArgs e)
{
try 
{
if (player != null)
{
player.Stop();
}
}
catch (Exception ex
{
Trace.Write(ex.Message);
}
}
友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内