Quick links:
F-IN-BOX .NET Edition Home Page
| Buy license
| Welcome to our forum!
| Ask your question
| Help on the Web
F-IN-BOX .NET Help Features
Features
It is known fact that the Flash Player ActiveX is able to load movies at certain URLs only. You have to save the movie to a temporary location from your application's resource before you can load it. You'll have to generate a corresponding link that you can pass to the Flash Player ActiveX and then delete the movie after. You'll have to admit that this is extremely inconvenient. Apart from being inconvenient there is a chance you'll fail when you try to create a temporary file if you don't have the appropriate permission or don't have access to a temporary folder. It is definitely not an appropriate approach when security is an issue since your movie can be easily intercepted. There is a solution! F-IN-BOX uses a different approach of swflash.ocx/flash.ocx code loading. It is able to load your movies directly to the Macromedia Flash Player ActiveX thereby avoiding the temporary file step. The advantages are pretty obvious. And you can also protect your movies from unauthorized access using your favourite software protection application. Using the component you can load any flash movie from memory directly. Just use the LoadMovieFromStream and PutMovieFromStream methods. No temporary files! Load any movie on-the-fly from any supported source. For example, you can put one or more flash movies in the resource section of your application and then load it from the exe! That's the portability and power of F-IN-BOX! Here's an example of how to load a flash movie from a resource: [ C# ]
private f_in_box__lib.f_in_box__control f_in_box__control1; ... f_in_box__control1.PutMovieFromStream( this.GetType().Assembly. GetManifestResourceStream("Sample1_SWF_And_FLV_Player.Embedded_Movies.movie.swf")); [ VB.Net ]
Friend WithEvents f_in_box__control1 As f_in_box__lib.f_in_box__control ... f_in_box__control1.PutMovieFromStream( _ Me.GetType().Assembly. _ GetManifestResourceStream("Sample1_SWF_And_FLV_Player.movie.swf"))
Create flash-enabled applications which are ready to work even when the Macromedia Flash Player ActiveX is not installed! One of the biggest problem using the Flash Player ActiveX is the mandatory component registration. The common approach is to save swflash.ocx/flash.ocx code to temporary files and then register them. The disadvantages are the same as above mentioned - insufficient permissions to save and register an swflash.ocx/flash.ocx. Now you can forget about these problems! F-IN-BOX is able to use swflash.ocx/flash.ocx from any source. For example, you can put an swflash.ocx/flash.ocx code inside of your application's resources and instruct F-IN-BOX to use it. It is important to note that F-IN-BOX does not use temporary files and swflash.ocx/flash.ocx registration but loads and uses the code directly. No more user management rights problems - no more temporary files and no more component registrations. It is up to you to decide what swflash.ocx/flash.ocx to use - by default already registered component is used. Traditionally, there are many obstacles or annoyances that one will encounter when using Macromedia Flash Player ActiveX in an application. The Application...
F-IN-BOX to the rescue. It solves these problems and more! By default, the component will use the swflash.ocx/flash.ocx that's already installed on the system. The component can alternatively use any swflash.ocx/flash.ocx that you would like to provide it with using any supported source. An example of this how you can embed the flash.ocx into the resource section of your application's exe file and then load it at runtime. Using this method, your application will work even if the Macromedia Flash Player ActiveX doesn't exist on the target system. With F-IN-BOX, hassling around with Macromedia Flash Player ActiveX installation issues are a thing the past! It's so easy to do! There are even demos provided which come complete with source code to prove it! Here's an example of how to load swflash.ocx/flash.ocx code from a resource: [ C# ]
private f_in_box__lib.f_in_box__control f_in_box__control1; ... private void MainForm_Load(object sender, System.EventArgs e) { // Loads flash.ocx from resource System.IO.Stream StreamWithFlashOCXCode = System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream("Sample3_StandalonePlayer.flash_ocx.flash.ocx"); if (StreamWithFlashOCXCode == null) { System.Windows.Forms.MessageBox.Show("Resource 'Flash.ocx' not found"); return; } f_in_box__lib.AxCode code = new f_in_box__lib.AxCode(StreamWithFlashOCXCode); f_in_box__control1 = new f_in_box__lib.f_in_box__control(code); Controls.Add(f_in_box__control1); } [ VB.Net ]
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles MyBase.Load 'Loads flash.ocx from resource Dim StreamWithFlashOCXCode As System.IO.Stream = _ Me.GetType().Assembly._ GetManifestResourceStream("Sample3_StandalonePlayer.flash.ocx") If StreamWithFlashOCXCode Is Nothing Then MsgBox("Resource 'Flash.ocx' not found") End If Dim code As New f_in_box__lib.AxCode(StreamWithFlashOCXCode) f_in_box__control1 = New f_in_box__lib.f_in_box__control(code) End Sub
Using F-IN-BOX you are able to create applications based on transparent flash movies. You can create applications with translucency non-rectangle forms. Use Flash to make applications with modern user interface, make a business logic using .NET. Use f_in_box__form component to work with transparency. Please note that form transparency is supported only under Win2k (or higher), 16 / 32 bpp display mode. To check if the transparency is supported use the function IsTransparentModeAvailable: [ C# ]
// Check transparent mode if (!f_in_box__lib.Global.IsTransparentModeAvailable) { System.Windows.Forms.MessageBox.Show("Transparent mode is not available"); return; } // MyTranslucencyForm is inherited from f_in_box__lib.f_in_box__form // Creating translucency form MyTranslucencyForm FlashPlayerForm = new MyTranslucencyForm(); // Loading movie from stream System.IO.Stream MovieStream = System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream("Sample4_Translucency.Embedded_Movies.movie.swf"); FlashPlayerForm.PutMovieFromStream(MovieStream); // Positions FlashPlayerForm.Width = 400; FlashPlayerForm.Height = 400; FlashPlayerForm.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2 - FlashPlayerForm.Width / 2; FlashPlayerForm.Top = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2 - FlashPlayerForm.Height / 2; // Play and... FlashPlayerForm.FlashMethod_Play(); // ...show FlashPlayerForm.Show(); Application.Run(FlashPlayerForm); [ VB.Net ]
' Check transparent mode If Not f_in_box__lib.Global.IsTransparentModeAvailable Then MessageBox.Show("Transparent mode is not available", _ Application.ProductName) Return End If ' MyTranslucencyForm is inherited from f_in_box__lib.f_in_box__form; ' Creating translucency form Dim FlashPlayerForm As New MyTranslucencyForm ' Loading movie from stream Dim MovieStream As System.IO.Stream = _ System.Reflection.Assembly.GetExecutingAssembly._ GetManifestResourceStream("Sample4_Translucency.movie.swf") FlashPlayerForm.PutMovieFromStream(MovieStream) ' Positions FlashPlayerForm.Width = 400 FlashPlayerForm.Height = 400 FlashPlayerForm.Left = _ Screen.PrimaryScreen.WorkingArea.Width() / 2 - _ FlashPlayerForm.Width / 2 FlashPlayerForm.Top = _ Screen.PrimaryScreen.WorkingArea.Height() / 2 - _ FlashPlayerForm.Height / 2 ' Play and... FlashPlayerForm.FlashMethod_Play() ' ...show FlashPlayerForm.Show() Application.Run(FlashPlayerForm)
Using F-IN-BOX you are able to play Flash Video (FLV) from external files, URL or directly from a stream. When F-IN-BOX loads Flash Video no temporary files are created everything runs directly from memory. You can encrypt your video and put into application's resource - F-IN-BOX loads FLV without ever saving or extracting the file to disk. To play Flash Video from stream you should create flash movie that loads Flash Video from "private" URL (http://FLV/FlashVideo.flv). Flash Movie uses the following code to load Flash Video: [ ActionScript ]
var netConn:NetConnection = new NetConnection(); netConn.connect(null); var netStream:NetStream = new NetStream(netConn); my_video.attachVideo(netStream); netStream.setBufferTime(0); netStream.play("http://FLV/FlashVideo.flv"); When Flash tries to load Flash Video from http://FLV/FlashVideo.flv, F-IN-BOX provides content of FLV. Use the event OnLoadExternalResourceByFullPath to set handle the external resources and provide them to Flash. See the code: [ C# ]
f_in_box__control1.AxCode.OnLoadExternalResourceByFullPath += new f_in_box__lib.AxCode. OnLoadExternalResourceByFullPathEventHandler(OnLoadExternalResourceByFullPath); ... private void OnLoadExternalResourceByFullPath( object sender, String URL, System.IO.Stream Stream, ref bool Handled) { if (URL == "http://FLV/FlashVideo.flv") { System.IO.Stream FLVStream = this.GetType().Assembly. GetManifestResourceStream("Sample2_SWF_FLV_Embedding.Embedded_Movies.flashvideo.flv"); const int size = 64 * 1024; byte[] buffer = new byte[size]; int ReadBytes; while ( (ReadBytes = FromStream.Read(buffer, 0, size)) > 0 ) { try { Stream.Write(buffer, 0, size); } catch (System.IO.IOException e) { // Loading is interrupted break; } } Stream.Close(); Handled = true; } } [ VB.Net ]
Private Sub OnLoadExternalResourceByFullPath(_ ByVal sender As Object, _ ByVal URL As String, _ ByVal Stream As System.IO.Stream, _ ByRef Handled As Boolean _ ) If URL = "http://FLV/FlashVideo.flv" Then Dim FLVStream As System.IO.Stream = _ Me.GetType().Assembly. _ GetManifestResourceStream("Sample2_SWF_FLV_Embedding.flashvideo.flv") ' You can write all content right here, but if FLVStream ' is BIG it takes long time ' The form will be unaccessible for user all this time ' Another option is to save Stream and write content in a ' separate thread ' You can find code example in the sample Sample1_SWF_And_FLV_Player Const nSize = 64 * 1024 Dim buffer(nSize) As Byte Dim nReadBytes As Integer While (True) nReadBytes = FLVStream.Read(buffer, 0, nSize) If 0 = nReadBytes Then Exit While Try ToStream.Write(buffer, 0, nReadBytes) Catch e As System.IO.IOException ' Loading is interrupted Exit While End Try End While Stream.Close() Handled = True End If End Sub
Using the library you can turn on/off flash sounds. Use property AxCode.SoundEnabled. [ C# ]
f_in_box__control1.AxCode.SoundEnabled = false; [ VB.Net ]
f_in_box__control1.AxCode.SoundEnabled = False
Using the library you can adjust sound volume. Use property AxCode.SoundVolume. To get maximum sound volume use f_in_box__lib.AxCode.MaxSoundVolume. [ C# ]
f_in_box__control1.AxCode.SoundVolume = f_in_box__lib.AxCode.MaxSoundVolume / 2; [ VB.Net ]
f_in_box__control1.AxCode.SoundVolume = f_in_box__lib.AxCode.MaxSoundVolume \ 2
You can get a bitmap image from the current frame of a flash movie. It means you are able create applications that can coverts Flash movies to a series of bitmaps, JPEGs and others. Also you can build generated images to make an AVI video for example. f_in_box__lib.f_in_box__form.GetBitmap() returns a bitmap with alpha channel. [ C# ]
Bitmap bmpWithoutAlpha = f_in_box__control1.GetBitmap(); Bitmap bmpWithAlpha = f_in_box__form1.GetBitmap(); ... f_in_box__control2.TransparentMode = true; f_in_box__control2.FlashProperty_Movie = "..."; Bitmap bmpWithAlphaToo = f_in_box__control2.GetBitmap(); [ VB.Net ]
Dim bmpWithoutAlpha As Bitmap = f_in_box__control1.GetBitmap() Dim bmpWithAlpha As Bitmap = f_in_box__form1.GetBitmap() ... ... f_in_box__control2.TransparentMode = True f_in_box__control2.FlashProperty_Movie = "..." Dim bmpWithAlphaToo As Bitmap = f_in_box__control2.GetBitmap()
F-IN-BOX supports External API. You can call functions of a movie and a movie is able to get data from an application synchronously (instead of fscommand).
Call an ActionScript function from an application
Register your function using ExternalInterface.addCallback: [ ActionScript ]
import flash.external.*; ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction); function InternalFunction(str: String): String { TextArea1.text = str; return "The function was called successfully"; } Use method CallFunction: [ C# ]
string Response = f_in_box__control1.FlashMethod_CallFunction( "<invoke name=" + """" + "CallMeFromApplication" + """" + " returntype=" + """" + "xml" + """" + "><arguments><string>Some text for F-IN-BOX.NET</string></arguments></invoke>"); MessageBox.Show("The function returned: '" + Response + "'"); [ VB.Net ]
Dim Response As String = _ f_in_box__control1.FlashMethod_CallFunction(_ "<invoke name=" + """" + "CallMeFromApplication" + """" + " returntype=" + _ """" + "xml" + """" + "><arguments><string>Some text _ for F-IN-BOX.NET</string></arguments></invoke>") MsgBox("The function returned: '" + Response + "'") Call an application function from a flash script Use flash.external.ExternalInterface.call: [ ActionScript ]
on (click) { _root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction"); } Handle event OnFlashCall: [ C# ]
private void f_in_box__control1_OnFlashCall( object sender, string request) { f_in_box__control1.FlashMethod_SetReturnValue( "Current time is: " + System.DateTime.Now.ToString() + ""); } [ VB.Net ]
Private Sub f_in_box__control1_OnFlashCall( _ ByVal sender As Object, _ ByVal request As String) Handles f_in_box__control1.OnFlashCall f_in_box__control1.FlashMethod_SetReturnValue(_ "Current time is: " + System.DateTime.Now.ToString() + "") End Sub
Write code which is compatible with any version of Macromedia Flash Player ActiveX (3, 4, 5, 6, 7, 8, 9, 10) One of the problem with Macromedia Flash Player ActiveX programming is that you have to control what version of Macromedia Flash Player ActiveX you are using. For example, the property "Stacking" exists only in Macromedia Flash Player ActiveX 5 but doesn't exist in later revisions. F-IN-BOX automatically detects what Macromedia Flash Player ActiveX version is being used and prevents failure if access to non existant properties/methods is attempted. Applications using F-IN-BOX are not only compatible with Macromedia Flash Player ActiveX 3, 4, 5, 6, 7, 8, 9, 10, but are also "smart" about how Macromedia Flash Player ActiveX control is used. This makes your application more robust which can result in fewer technical support issues.
Copyright © Softanics. All rights reserved. F-IN-BOX is a trademark of Softanics. Macromedia and Shockwave Flash are trademarks of Adobe
Quick links:
F-IN-BOX .NET Edition Home Page
| Buy license
| Welcome to our forum!
| Ask your question
| Help on the Web
|