why not have SetGlobalOnLoadExternalResourceHandlerAsyncEx?

F-IN-BOX for Delphi / Builder C++ / VCL
duhast
Posts: 6
Joined: Wed Nov 11, 2009 9:28 am

why not have SetGlobalOnLoadExternalResourceHandlerAsyncEx?

Postby duhast » Tue Dec 01, 2009 6:13 am

why not have SetGlobalOnLoadExternalResourceHandlerAsyncEx to set handle when flash loads FLV video using a relative path

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: why not have SetGlobalOnLoadExternalResourceHandlerAsync

Postby Softanics » Tue Dec 01, 2009 6:21 pm

Thank you for your question.

duhast wrote:why not have SetGlobalOnLoadExternalResourceHandlerAsyncEx to set handle when flash loads FLV video using a relative path


Because it seems that SetGlobalOnLoadExternalResourceHandlerAsync is enough.

If you load the main movie using path e.g. "C:\movie.swf". Then this movie requests FLV using relative path "video/1.flv", the global handler (which set by SetGlobalOnLoadExternalResourceHandlerAsync) is called. The path to the video and a reference to a TStream are passed to the handler.

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

duhast
Posts: 6
Joined: Wed Nov 11, 2009 9:28 am

Postby duhast » Wed Dec 02, 2009 1:01 am

Yes,you're right,but i can't handled it,for example,when flash loads two large files,the application raise fatal error.maybe there is a method to use thread like 'SetGlobalOnLoadExternalResourceHandlerEx'.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Wed Dec 02, 2009 10:24 am

duhast wrote:Yes,you're right,but i can't handled it,for example,when flash loads two large files,the application raise fatal error.maybe there is a method to use thread like 'SetGlobalOnLoadExternalResourceHandlerEx'.


There are two cases.

1. A movie is loaded using "http://blablabla/movie.swf". Then the movie tries to load "/videos/video1.flv". You handle this video by SetGlobalOnLoadExternalResourceHandlerEx.

You can create a thread within the handler that is set by SetGlobalOnLoadExternalResourceHandlerEx:

Code: Select all

procedure TMainForm.GlobalOnLoadExternalResourceHandlerEx(const URL: WideString; Stream: TStream; out bHandled: Boolean)
begin
    if URL = 'http://blablabla/videos/video1.flv' then
    begin
        bHandled := true;

        TMyThread.Create(Stream); // this thread writes data to passed TStream
    end;
end;


2. A movie is loaded using "C:\blablabla\movie.swf". Then the movie tries to load "/videos/video1.flv". You handle this video by SetGlobalOnLoadExternalResourceHandlerAsync. Instead of case #1, Flash uses file operations here, so f-in-box intercepts calls from flash to functions like CreateFile / CloseHandle etc.; f-in-box provides a fake file handle, so when flash calls ReadFile from this fake file handle, it really calls a TStream that was returned by a handler (SetGlobalOnLoadExternalResourceHandlerAsync).

Code: Select all

procedure TMainForm.FlashPlayerControl1LoadExternalResourceAsync(
  ASender: TObject; const Path: WideString; out Stream: TStream);
begin
    if Path = 'videos\video1.flv' then
       Stream := TResourceStream.Create(0, 'FlashVideo', 'FLV');
end;


Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

duhast
Posts: 6
Joined: Wed Nov 11, 2009 9:28 am

Postby duhast » Wed Dec 02, 2009 1:34 pm

Thank you very much,I understand.


Return to “Delphi / Builder / VCL Edition”

Who is online

Users browsing this forum: No registered users and 24 guests