运行时MediaPlayer创建:如何正确初始化Ocxstate? [英] Runtime MediaPlayer creation: how to properly initialize Ocxstate?
本文介绍了运行时MediaPlayer创建:如何正确初始化Ocxstate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个MediaPlayer类,以便可以在运行时生成实例,但始终会得到无效的Ocxstate. ,所以我尝试的方法不正确.
如何使它起作用?
Hi,
I am trying to create a MediaPlayer class so I can generate instances at runtime, but keep getting an invalid Ocxstate.
Uncommenting the commented-out Ocx statement does not help, so what I tried is incorrect.
How can I get this to work?
class MyMediaPlayer : AxWMPLib.AxWindowsMediaPlayer
{
public MyMediaPlayer(string name)
{
// without OcxState set, throws InvalidActiveXStateException when a MyMediaPlayer instance is used
ComponentResourceManager resources = new ComponentResourceManager();
((ISupportInitialize)(this)).BeginInit();
// OcxState = ((AxHost.State)(resources.GetObject(name + ".OcxState")));
((ISupportInitialize)(this)).EndInit();
}
}
推荐答案
您是否按照以下步骤创建了互操作包装程序?
Did you follow these steps to create your interop wrapper?
http://msdn.microsoft.com/en-us/library/ms742735.aspx
这篇关于运行时MediaPlayer创建:如何正确初始化Ocxstate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文