精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
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); } }