Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;using system.io;using system.xml;using axshockwaveflashobjects;/* * VS2005 add shockwave When a lot of people have encountered a problem, is to say that the ActiveX registration failure * First to register ActiveX with Regsvr32 (run: Regsvr32 control name)-U is the unload parameter * Regsvr32 c: \ Windows\system32\macromed\flash\flash32_18_0_0_203.ocx-u * Regsvr32 C:\WINDOWS\system32\Macromed\Flash\Flash32_18 _0_0_203.ocx * under VS2005 Project-Properties-build-target platform changed to x86 the yellow exclamation point of axshochwaveflashobj under Select Build-Clean solution and rebuild solution until explorer references */namespace adobeflashplaydemo{//<summary>//http://www.codeproject.com/Articles/12010/ FUN-WITH-C-AND-THE-FLASH-PLAYER-EXTERNAL-API//http://www.codeproject.com/Articles/10863/ Flash-and-net-with-flashremoting//http://www.codeproject.com/Articles/15742/ Multiple-file-upload-with-progress-bar-using-flash//http://www.codeproject.com/Articles/12928/ Flash-gui-for-your-exe-using-minimalistic-approach//</sumMary> public partial class Flvplayer:form {//private statusbarpanel Filenamestatusbarpanel; <summary>//////</summary> public Flvplayer () {Initialize Component (); This.filenamestatusbarpanel = new System.Windows.Forms.StatusBarPanel (); try {axshockwaveflash1.loadmovie (0, Application.startuppath + "\\player.swf"); Axshockwaveflash1.flashcall + = new _ishockwaveflashevents_flashcalleventhandler (Flashplayer_flashcall); } catch (Exception ex) {exceptionutilities.displayexception ("Unable to load SWF vide o Player, please verify you have Flash player 8 installed and try again. "); This. Dispose (); }}///<summary>///</summary>//<param name= "Moviepath" >< ;/param> public Flvplayer (String MoviepATH): this () {this. Loadvideo (Moviepath); }//<summary>///</summary>//<param name= "Sender" ></param> <param name= "E" ></param> private void Form1_Load (object sender, EventArgs e) { }//<summary>///</summary>//<param name= "Sender" ></param> <param name= "E" ></param> private void Button1_Click (object sender, EventArgs e) { Openvideodialog = new OpenFileDialog (); Openvideodialog.filter = "*.flv|*.flv"; Openvideodialog.title = "Select a Flash Video file ..."; Openvideodialog.multiselect = false; Openvideodialog.restoredirectory = true; if (openvideodialog.showdialog () = = DialogResult.OK) {loadvideo (openvideodialog.filename); }}//<Summary>/////</summary>//<param name= "Videopath" ></param> private void Loadvideo (String videopath) {filenamestatusbarpanel.text = Videopath; Axshockwaveflash1.callfunction ("<invoke name=\" loadandplayvideo\ "returntype=\" xml\ "><arguments>< String> "+ Videopath +" </string></arguments></invoke> "); }//<summary>///</summary>//<param name= "Sender" ></param> <param name= "E" ></param> private void Flvplayer_dragdrop (object sender, DragEventArgs e) {string[] files = (string[]) e.data.getdata (DataFormats.FileDrop); if (filenamestatusbarpanel.text! = Files[0]) {Loadvideo (files[0]); }}///<summary>///</summary>//<param name= "Sender" ></p Aram> <param name= "E" ></param> private void Flvplayer_dragenter (object sender, DragEventArgs e) {if (E.data.getdatapresent (DataFormats.FileDrop, False)) {e.effect = Dragdropef Fects. All; }}///<summary>///</summary>//<param name= "Sender" ></p aram>//<param name= "E" ></param> private void Flvplayer_dragleave (object sender, EventArgs e) {}///<summary>///</summary>//<param name= "width" & gt;</param>//<param name= "height" ></param> public void Resizeplayer (int width, int Heig HT) {axshockwaveflash1.width = Width; Axshockwaveflash1.height = Height; Videoplaceholder.width = Width; Videoplaceholder.height = Height; } private void Flashplayer_flashcall (ObjeCT sender, _ishockwaveflashevents_flashcallevent e) {XmlDocument document = new XmlDocument (); Document. LOADXML (e.request); Since I has only one call back I just grab the arguments and call/the function. This needs to is made much more flexible when there is//multiple call backs going back and forth XmlNodeList list = document. getElementsByTagName ("arguments"); Resizeplayer (Convert.ToInt32 (list[0). Firstchild.innertext), Convert.ToInt32 (List[0]. CHILDNODES[1]. InnerText)); }//<summary>///</summary>//<param name= "Sender" ></param> <param name= "E" ></param> private void Axshockwaveflash1_flashcall (object sender, _ishockwave Flashevents_flashcallevent e) {XmlDocument document = new XmlDocument (); Document. LOADXML (e.request); Since I has only one call backI just grab the arguments and call/the function. This needs to is made much more flexible when there is//multiple call backs going back and forth XmlNodeList list = document. getElementsByTagName ("arguments"); Resizeplayer (Convert.ToInt32 (list[0). Firstchild.innertext), Convert.ToInt32 (List[0]. CHILDNODES[1]. InnerText)); private void Axshockwaveflash1_enter (object sender, EventArgs e) {}}}
Csharp:flash Player play *.flv file in WinForm