F-IN-BOX .NET Help >> Classes >> AxCode >> Events

OnLoadExternalResourceByFullPath

Syntax

[ C# ]
  1. public delegate void OnLoadExternalResourceByFullPathEventHandler(object sender, String URL, Stream Stream, ref bool Handled);  
  2. public event OnLoadExternalResourceByFullPathEventHandler OnLoadExternalResourceByFullPath;  

Description

OnLoadExternalResourceByFullPath is called when flash tries to load a resource addressed by full (not relative) URL, for example: http://tratata/1.swf.

[ C# ]
  1. private void OnLoadExternalResourceByFullPath(object sender, String URL, System.IO.Stream Stream, ref bool Handled)  
  2. {  
  3.     if (URL == "http://FLV/FlashVideo.flv")  
  4.     {  
  5.         System.IO.Stream FromStream = System.IO.File.OpenRead(Path);  
  6.   
  7.         FromStreamToStreamWriter writer =   
  8.             new FromStreamToStreamWriter(  
  9.                 FromStream,   
  10.                 Stream  
  11.             );  
  12.   
  13.         Handled = true;  
  14.     }  
  15. }  

[ VB.Net ]
  1. Private Sub OnLoadExternalResourceByFullPath(ByVal sender As ObjectByVal URL As StringByVal Stream As System.IO.Stream, ByRef Handled As Boolean)  
  2.     If URL = "http://FLV/FlashVideo.flv" Then  
  3.         Dim FLVStream As System.IO.Stream = Me.GetType().Assembly.GetManifestResourceStream("Sample2_SWF_FLV_Embedding.flashvideo.flv")  
  4.   
  5.         ' You can write all content right here, but if FLVStream is BIG it takes long time  
  6.         ' The form will be unaccessible for user all this time  
  7.         ' Another option is to save Stream and write content in a separate thread  
  8.         ' You can find code example in the sample Sample1_SWF_And_FLV_Player  
  9.   
  10.         Const nSize = 64 * 1024  
  11.   
  12.         Dim buffer(nSize) As Byte  
  13.   
  14.         Dim nReadBytes As Integer  
  15.   
  16.         While (True)  
  17.             nReadBytes = FLVStream.Read(buffer, 0, nSize)  
  18.   
  19.             If 0 = nReadBytes Then Exit While  
  20.   
  21.             Try  
  22.                 Stream.Write(buffer, 0, nReadBytes)  
  23.             Catch e As System.IO.IOException  
  24.                 ' Loading is interrupted  
  25.                 Exit While  
  26.             End Try  
  27.         End While  
  28.   
  29.         Stream.Close()  
  30.   
  31.         Handled = True  
  32.     End If  
  33. End Sub  


Copyright © Softanics. All rights reserved.
F-IN-BOX is a trademark of Softanics.
Macromedia and Shockwave Flash are trademarks of Adobe