Youtube Video auf einbinden

Liebe Leute!

Ich habe eine kurze Frage:
Ich probiere gerade ein youtube-Video in mein Programm einzubinden. Dazu habe ich einen Webbrowser erstellt und den Origianllink
zu diesem hier (wie auch auf Turtorials beschrieben) umgeändert
Dann kommt aber immer ein Fehler im Script

Hier die Fehlerbeschreibung:…

Bitte um Hilfe!

Vielen Dank, Philipp


ich habe vor längerer zeit mal ein q’nd tutorial für C# geschrieben (englisch).
das vorgehen ist das selbe, den code müsstest du auf anpassen.

"Flash integration into a windows form (or a wpf page via winformhost).

usually you have to start with the compilation of the dll with a tool called aximp.exe
(could be found at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools for example).
if this folder doesn’t exist under the normal location (^^this one is on a 64bit system),
you need to install the windows sdk at first (btw. try to search on c:).
if you have found aximp.exe, open a cmd (as admin) navigate to the folder where aximp.exe is stored.
type: aximp[.exe] /source „%windir%\system32\macromed\flash\Flash_YOUR_VERSION.ocx“. this command creates
a few new files in your folder where aximp is located:

  • AxShockwaveFlashObjects.dll //the dll where the needed flashobject is stored

  • AxShockwaveFlashObjects.cs //the sourcecode for the AxShockwaveFlashObjects.dll

  • AxShockwaveFlashObjects.pdb //program debug db

  • ShockwaveFlashObjects.dll //the interop library where the interop types are stored

this files are needed for your project - now you could simply add these dlls as references
and you’re be able to create a flashobject in your project.

you are now only be able to create this object completly via sourcecode - and this could suck!
if you try to add AxShockwaveFlashObjects.dll to your vs-toolbox you’ll get an error like:
„Failed to import ActiveX control. Make sure it is properly registered.“

why you get this error? simply the dll is not addable to vs until the following line of code would
be added to AxShockwaveFlashObjects.cs (!):


so open AxShockwaveFlashObjects.cs and add the attribut to the first class definition, and compile
the .cs to a new dll (AxShockwaveFlashObjects.dll). you could create a new vs-project and add ShockwaveFlashObjects.dll as reference,
or simply compile it via csc.exe (stored in your target .net framework folder) with the command:

csc.exe /t:library /r:COM.dll /out:AxShockwaveFlashObjects.dll AxShockwaveFlashObjects.cs

since you have compiled this new dll, you’re be able to add this dll to the vs toolbox.
you could do it simply via drag&drop, or per right click in your toolbox -> select element -> find/search
-> navigate to, and add the new compiled dll to vs -> ok
now you should have a small gear sign in your toolbox. open a new winforms project, and drag&drop this gear sign into your form.
now you have the naked flash-host (axShockwaveFlash1) in your form and could implement the logic.


adding a video file to axShockwaveFlash1:

define a string with the path of the stored swf-file:  

    string myFlashFile = Application.StartupPath + @"\myflash.swf";

adding the string as content to the axShockwaveFlash1 object:  

    axShockwaveFlash1.Movie = myFlashFile;

Adding two buttons below your axShockwaveFlash1 object in your form.  
btn1: btnPlay  
btn2: btnStop  
adding the ClickEventhandlers and type in the folowing lines:  

    axShockwaveFlash1.Play(); //for playing the "video"


    axShockwaveFlash1.Stop(); //for stopping the "video"

Thats it, now you have implemented a simple logic and a flashcontent to your windowsforms project.  
for furthermore details like looping, check if the "video" is playing or paused, use google for the win :smile:"  
greetz, me