Работа с Flash
Работа с Flash
Работа с Flash How to play flash movie inside applications ActiveX ShockwaveFlash plays flash movies, it is in the library flash.ocx of Macromedia, Inc. (earlier versions were called swflash.ocx). So the first requirement is this library must be installed. As a rule, it is in the folder [Win_system]\Macromed\Flash\, for example C:\Windows\system32\Macromed\Flash\. If not you should install the one before starting of application. Also, you should use ActiveX component TShockwaveFlash in your application. It contains as property Movie so other various methods to manage movie playing - Play, Stop, Rewind etc. Some examples of ActiveX using are at the Using TShockwaveFlash part. How to install Flash.ocx into system Macromedia provides the on-line installing of player at its web-site. So you can install the newest version of the player free clicking this link. Once everyone, surfing Internet, opens site with Flash and if the Flash player has not been installed yet, the browser offers to do that, so it is very probable that the Flash players are on almost all computers connected to Internet. If the application must be installed there are some tips how to do that. It is better to set the one during your application installing for the flash.ocx library would be available for other applications. Almost all software for installation making can do that: InstallShield, InstallWizard, InnoSetup, GhostInastall etc. Your program can do that too: copy flash.ocx to the system folder or the application folder and register it. {Register the OCX File} // set LibraryDir // LibraryDir := ExtractFilePath(Application.ExeName); // or // LibraryDir := SystemDir; aHandle := LoadLibrary(PChar(LibraryDir + 'flash.ocx')); if ( aHandle >= 32 ) then begin aFunc := GetProcAddress( aHandle, 'DllRegisterServer' ); if Assigned( aFunc ) then begin GetShortPathName( PChar(LibraryDir + 'flash.ocx'), aShortPath, sizeOf(aShortPath)); aCommand := Format( '%s\regsvr32.exe /s %s', [SystemDir, aShortPath] ); WinExecAndWait32( aCommand, SW_HIDE ); end; FreeLibrary( aHandle ); end; How to install Flash.ocx into Delphi IDE In Delphi click the menu Component -> Import ActiveX Control... Choose "Shockwave Flash" from the list of available objects or brows the file Flash.ocx and import it. The TShockwaveFlash component will appear in the ActiveX tab. You can use Delphi package prepared by us. You should do the following: Open project > choose FlashAX.dpk > Install. The TShockwaveFlash and TShockwaveFlashEx components will appear in the ActiveX tab. TShockwaveFlashEx is an advanced component, learn more... Simple playing For example, there is a task to play sample.swf which is in the same folder that the application is. Put the TShockwaveFlash component to the form and rename the one into FlashPlayer. Then: procedure TmDemo.FormCreate(Sender: TObject); begin FlashPlayer.Movie := ExtractFilePath(Application.ExeName) + 'sample.swf'; labelInfo.Caption := Format('%d frames', FlashPlayer.TotalFrames); FlashPlayer.Play; end; procedure TmDemo.bStopClick(Sender: TObject); begin FlashPlayer.Stop; end; procedure TmDemo.bPlayClick(Sender: TObject); begin FlashPlayer.Play; end;