How to know end of file or play ending of flv file ?

F-IN-BOX for Delphi / Builder C++ / VCL
porny2
Posts: 2
Joined: Wed Oct 31, 2007 9:45 am

How to know end of file or play ending of flv file ?

Postby porny2 » Wed Oct 31, 2007 6:42 pm

How to know the end of file or play ending of flv file ?

TFlaashPlayerControl

When Load Stream and play follow the code example And How to know end of file or play ending of flv file ?

Thank.

ps. sorry for my english language.

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

Postby Softanics » Wed Oct 31, 2007 8:20 pm

Thank you for your question.

Yes, that's possible.

As you probably know, you should use a SWF movie with FLV player inside to play FLV. Such movie contains actionscript code like that:

Code: Select all

var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
my_video.attachVideo(netStream);


To play:

Code: Select all

_root.netStream.play(url);


To get current time position of video:

Code: Select all

_root.netStream.time;


I've uploaded the movie.

Source:
http://f-in-box.com/misc/delphi_end_flv ... player.fla

SWF:
http://f-in-box.com/misc/delphi_end_flv ... player.swf

How to use.

You load the SWF. After that you provide a FLV URL:

Code: Select all

flashplayercontrol1.SetVariable('flv_url', '...URL here...');


To get current time position you call something like that:

Code: Select all

   CurPos: Integer;
...
   CurPos := StrToInt(flashplayercontrol1.GetVariable('flv_current_time'));


Get CurPos periodically (use TTimer, for example) each... for example, 500 ms. If 5 (for example!) times, you receive the same value -- it seems that FLV reaches the end.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

porny2
Posts: 2
Joined: Wed Oct 31, 2007 9:45 am

Postby porny2 » Thu Nov 01, 2007 2:06 am

In Delphi. How to get count loop of play flv file ?

Thank in advanced.

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

Postby Softanics » Thu Nov 01, 2007 9:17 am

porny2 wrote:In Delphi. How to get count loop of play flv file ?

Thank in advanced.


What's "count loop"?...
Best regards, Artem A. Razin,

F-IN-BOX support

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

flegel
Posts: 12
Joined: Wed Mar 21, 2007 1:59 pm

Postby flegel » Thu Dec 20, 2007 4:19 pm

Hello,

This is an interesting topic. I have a followup question on this:

I got the flv to work this way (thus called from the swf), but
now I can only get the current time of the flv, I actually want the current frame AND the total number of frames of the flv, so I can compare those 2 to detect of the flv has ended.

Is this possible? How?


Also other question:
Is it also possible to play / stream a flv immediately (instead of loading it in memory) because if I use big flv files, the loading takes too long. I actually want it to stream / play immediately, also on slow computers.


Thanks in advance,
Martin

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

Postby Softanics » Thu Dec 20, 2007 7:58 pm

Thank you for your questions.

flegel wrote:I got the flv to work this way (thus called from the swf), but
now I can only get the current time of the flv, I actually want the current frame AND the total number of frames of the flv, so I can compare those 2 to detect of the flv has ended.

Is this possible? How?


I don't know a simple way. The only way is to parse the file, get timestamps for each frame. Why you don't like the way when you periodically test current time position?

flegel wrote:Also other question:
Is it also possible to play / stream a flv immediately (instead of loading it in memory) because if I use big flv files, the loading takes too long. I actually want it to stream / play immediately, also on slow computers.


Yes, of course, just pass the path / URL of a FLV:

Code: Select all

flashplayercontrol1.SetVariable('flv_url', '...URL here...');


You can also provide flv content from memory piece-by-piece, so that's not a problem: the playing starts immediately in this case too.
Best regards, Artem A. Razin,

F-IN-BOX support

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

flegel
Posts: 12
Joined: Wed Mar 21, 2007 1:59 pm

Postby flegel » Sat Dec 29, 2007 5:28 pm

If I only know the current time of the movie (and not the total time of the movie) then I still dont know if the movie is at its end.

I have to know either the current time and the total time of the movie or (preferable) the current frame and total number of frames of the movie.

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

Postby Softanics » Sun Dec 30, 2007 6:37 pm

flegel wrote:If I only know the current time of the movie (and not the total time of the movie) then I still dont know if the movie is at its end.

I have to know either the current time and the total time of the movie or (preferable) the current frame and total number of frames of the movie.


Yes, total time is unknown. Not sure but total time could be located in metadata.

But you still can monitor the current time position.
Best regards, Artem A. Razin,

F-IN-BOX support

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

HansvL
Posts: 1
Joined: Fri Apr 18, 2008 9:50 am

Postby HansvL » Fri Apr 18, 2008 10:16 am

Hi, I am trying to read time as suggested with GetVariable('flv_current_time') using the SWF as you provided.

However, I get "unspecified error" when try to read the variable.
I do not have Flash program but with hex viewer I can see that flv_current_time is defined in the flash, so I am using the correct SWF.

Do you have any suggestions please? Thanks!

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

Postby Softanics » Fri Apr 18, 2008 8:04 pm

HansvL wrote:Hi, I am trying to read time as suggested with GetVariable('flv_current_time') using the SWF as you provided.

However, I get "unspecified error" when try to read the variable.
I do not have Flash program but with hex viewer I can see that flv_current_time is defined in the flash, so I am using the correct SWF.

Do you have any suggestions please? Thanks!


Thank you for your question.

Are you sure that you use this new SWF? If you load this SWF from resource, you should rebuild .res file and then rebuild the project.
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 17 guests