Something about the new version

F-IN-BOX for Delphi / Builder C++ / VCL
coolshadow
Posts: 67
Joined: Fri Oct 10, 2008 7:42 am

Something about the new version

Postby coolshadow » Thu Nov 20, 2008 7:15 am

From this forum,I saw that you released a new version.
I got a look at the help file and found that a new event was added(I have not install the new demo version and test it).
OnLoadExternalResourceAsync

But Now ,I has a question or an advise.

As you've said in the help file,I found a question.
Like this.
A flv file was encrypted and stored in resource. So before play it ,you must dencrypt it.
But the flv file was very large, So in the old version ,we use OnLoadExternalResourceEx, by using this,we can streaming it.

In the new version,even if you use OnLoadExternalResourceAsync.

At this time,if the flv file is encrypted and is very large, you will also spend a lot of time to dencrypt the whole flv file.

So my advise is how can we use streaming when using OnLoadExternalResourceAsync??

If the video was first called, we new a tstream and read some datas, then after some time,we read some other datas.

HeHe,may be my advise is a fantastic idea .

Thanks :wink:

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

Postby Softanics » Thu Nov 20, 2008 8:37 am

Thank you for your question.

When you use OnLoadExternalResourceEx you push data to a TStream. When you use OnLoadExternalResourceAsync, Flash reads data from a TStream you've provided.

Why did we add OnLoadExternalResourceAsync? When one uses OnLoadExternalResourceEx, all data written to a TStream are presaved by Flash. If you have 1 Gb FLV, Flash saves all data, 1 Gb, in memory. Flash needs all data to change video position in any moment.

When OnLoadExternalResourceAsync is used, you provide a TStream with FLV data. When Flash want to change video position, it just call .Seek of the TStream. When it reads data, it calls TStream.Read. So all what you need in this case is to create a class that is derived from TStream and implement .Seek and .Read functions.

In the most cases, OnLoadExternalResourceEx is easy to implement. You just decrypt data and pass it to TStream. Very easy.

But if you should to implement TStream with encrypted data that implements .Seek, it's not easy task. Anyway, we will included a sample of this soon.

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

coolshadow
Posts: 67
Joined: Fri Oct 10, 2008 7:42 am

Postby coolshadow » Thu Nov 20, 2008 9:31 am

I think I have not described clearly.

When use OnLoadExternalResourceEx,flv file can be played when it have not been fully loaded. Am I right?

So as the same, can we let flv file be played when it have not been fully loaded in OnLoadExternalResourceAsync.

What I've said using streaming in OnLoadExternalResourceAsync means that, at begin, the data in stream was only some of the flv datas, but when app runs, the data begin more and more and at last ,it has all the flv datas.

So if we can use streaming in Onloadexternalresourceasync, we can save memory and can also have the advantage of onloadexternalresourceex

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

Postby Softanics » Thu Nov 20, 2008 9:41 am

coolshadow wrote:When use OnLoadExternalResourceEx,flv file can be played when it have not been fully loaded. Am I right?


Right.

coolshadow wrote:So as the same, can we let flv file be played when it have not been fully loaded in OnLoadExternalResourceAsync.


Yes, it will be played.

For example, you load FLV using "/videos/video1.flv". OnLoadExternalResourceAsyncHandler is called, you check passed path and provide your implementation of TStream, let's name it TStreamImplementation. Then Flash read header of FLV, it calls TStreamImplementation.Read(flv_header, sizeof(flv_header)), thet it read data block-by-block and show it. When you change video position, Flash calls TStreamImplementation.Seek( ... ), and then read data from the new position again. And so on.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

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

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

Postby Softanics » Thu Nov 20, 2008 9:44 am

By the way, one more important difference between OnLoadExternalResourceEx and OnLoadExternalResourceAsync. OnLoadExternalResourceEx is not called when Flash loads a FLV using a relative path, e.g. "/videos/video1.flv", it's called only when Flash loads a FLV using a full path, e.g. "http://videos/video1.flv". It was a problem for developers who deals with SWFs that loads FLV using a relative path. Now the problem has been solved.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

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

coolshadow
Posts: 67
Joined: Fri Oct 10, 2008 7:42 am

Postby coolshadow » Thu Nov 20, 2008 1:19 pm

Softanics wrote:
For example, you load FLV using "/videos/video1.flv". OnLoadExternalResourceAsyncHandler is called, you check passed path and provide your implementation of TStream, let's name it TStreamImplementation. Then Flash read header of FLV, it calls TStreamImplementation.Read(flv_header, sizeof(flv_header)), thet it read data block-by-block and show it. When you change video position, Flash calls TStreamImplementation.Seek( ... ), and then read data from the new position again. And so on.

Thank you.


So what I asked is that.
Can the memory of TStreamImplementation be changed by us.

For example.
May be there is a event called OnLoadExternalResourceAsyncEx :oops:

In this method, We first write some data to TStreamImplementation. Then flash read the data and play it like the flash did OnLoadExternalResourceAsync event(which means flash directlly use TStreamImplementation.seek when we change video position)
After some time, we write some other data to TStreamImplementation again. Then flash continue to play it.
We do this until all data of one flv file was write to TStreamImplementation.

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

Postby Softanics » Thu Nov 20, 2008 1:26 pm

coolshadow wrote:So what I asked is that.
Can the memory of TStreamImplementation be changed by us.

For example.
May be there is a event called OnLoadExternalResourceAsyncEx :oops:

In this method, We first write some data to TStreamImplementation. Then flash read the data and play it like the flash did OnLoadExternalResourceAsync event(which means flash directlly use TStreamImplementation.seek when we change video position)
After some time, we write some other data to TStreamImplementation again. Then flash continue to play it.
We do this until all data of one flv file was write to TStreamImplementation.


You can make any TStreamImplementation.

What's really important is to understand what and when Flash calls.

Due to your example, you would like to create TStreamImplementation like a pipe. No problems. You can :) Moreover, VCL already contains THandleStream that can help you. You can create two THandleStream based on pipe handles received from the call of winapi's CreatePipe.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

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

coolshadow
Posts: 67
Joined: Fri Oct 10, 2008 7:42 am

Postby coolshadow » Thu Nov 20, 2008 1:27 pm

Softanics wrote:By the way, one more important difference between OnLoadExternalResourceEx and OnLoadExternalResourceAsync. OnLoadExternalResourceEx is not called when Flash loads a FLV using a relative path, e.g. "/videos/video1.flv", it's called only when Flash loads a FLV using a full path, e.g. "http://videos/video1.flv". It was a problem for developers who deals with SWFs that loads FLV using a relative path. Now the problem has been solved.

Thank you.


Yes I know. :lol:

And there is another difference, in present version, Onloadexternalresourceex can use streaming, but onloadexternalresourceasync can not.

What I hoped is onloadexternalresourceasync can also use streaming.

:oops: :oops:

En, Can I ask one question?
Why not make the onloadexternalresourceex be called when load a flv file from a relative path. But add a new event?(So developers must handle all these events to make sure app runs well)
Is there some reason??

coolshadow
Posts: 67
Joined: Fri Oct 10, 2008 7:42 am

Postby coolshadow » Thu Nov 20, 2008 1:28 pm

Softanics wrote:
coolshadow wrote:So what I asked is that.
Can the memory of TStreamImplementation be changed by us.

For example.
May be there is a event called OnLoadExternalResourceAsyncEx :oops:

In this method, We first write some data to TStreamImplementation. Then flash read the data and play it like the flash did OnLoadExternalResourceAsync event(which means flash directlly use TStreamImplementation.seek when we change video position)
After some time, we write some other data to TStreamImplementation again. Then flash continue to play it.
We do this until all data of one flv file was write to TStreamImplementation.


Thanks ,I'll check it later :lol:
You can make any TStreamImplementation.

What's really important is to understand what and when Flash calls.

Due to your example, you would like to create TStreamImplementation like a pipe. No problems. You can :) Moreover, VCL already contains THandleStream that can help you. You can create two THandleStream based on pipe handles received from the call of winapi's CreatePipe.

Thank you.

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

Postby Softanics » Thu Nov 20, 2008 1:30 pm

coolshadow wrote:And there is another difference, in present version, Onloadexternalresourceex can use streaming, but onloadexternalresourceasync can not.


It depends on what Streaming is. In my opinion, Streaming is when you can provide content later, after Flash starts using of a resource. So onloadexternalresourceasync allows Streaming.

coolshadow wrote:En, Can I ask one question?
Why not make the onloadexternalresourceex be called when load a flv file from a relative path. But add a new event?(So developers must handle all these events to make sure app runs well)
Is there some reason??


BTW, very good question. We must think about that, you're right. I think, it's possible.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

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


Return to “Delphi / Builder / VCL Edition”

Who is online

Users browsing this forum: No registered users and 13 guests

cron