I have a HTML page that contains a flash file and some a JavaScript function that returns the object of the flash file.
So far I can call the JavaScript function from C# and have it return an Object, but I want to cast it as AxShockwaveFlash and access the COM Object directly from C#.
I have seen this done with Windows Media Player imbedded in the a HTML page, but it doesn’t seem to work with flash.
<script type="text/JavaScript"> function GetWMP() { return(testing); } <script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="857" height="480" id="testing">
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
</object>
Below is my C# code which returns the object.
object o = webBrowser1.Document.InvokeScript("ReturnFlash");
AxShockwaveFlashObjects.AxShockwaveFlash flash = (AxShockwaveFlashObjects.AxShockwaveFlash)o;
When I try to cast the Object to AxShockwaveFlash it fails, but I have seen it work casting the object to WindowsMediaPlayer.
I tried to find if AxShockwaveFlash supports QueryInterface calls, as per the error message but Google returned nothing of value.
Thanks
AxShockwaveFlash is an auto-generated Windows Forms control, created by aximp.exe. So you can put it on a form. That object you got is not that control. You can only cast to the interface exposed by the interop wrapper, which should be ShockwaveFlashObjects.ShockwaveFlash.