Playing FLV files (via MemoryStream / FileStream)

F-IN-BOX for Delphi / Builder C++ / VCL
flegel
Posts: 12
Joined: Wed Mar 21, 2007 1:59 pm

Playing FLV files (via MemoryStream / FileStream)

Postby flegel » Wed Apr 25, 2007 7:44 am

Hello,

I've been experimenting with f in the box flashplayercontrol to play
swf files in my directx app with Delphi.
And things went ok, I get about 10-15 fps (bitmap 800x600 pixels)
on a slow pentum 500 and about 40 fps on a Pentium IV 2 GHz.
Not very fast, but doable.

But now I also need to play FLV files in my directx app.
I just dont get it working (it should be loaded once from a memorystream).
I know there are an samples to play FLV and I've studied the code,
but when I start an app from scratch (and with different flv files)
it just doesn't work. And besides I also dont want to use .rc / .res files...
Also, it just isn't clear to me how it should work and I dont know
if it will work the way I want like I can do now with SWF files.

I actually just want to load a FLV file from a memorystream once (must come from a database field) and play it. (I also dont want to use .res files!)
How can I do that? What are the exact steps to just play a flv file?...

Could you maybe also give me a super simple snippet of delphi-code which does this task?

Thanks in advance
Regards,
Martin
--------

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

Re: Playing FLV files (via MemoryStream / FileStream)

Postby Softanics » Wed Apr 25, 2007 12:49 pm

Thank you for your question.

flegel wrote:but when I start an app from scratch (and with different flv files)
it just doesn't work.


What sample doesn't work?
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 Apr 26, 2007 5:14 am

Hi,

I didn't say a sample doesn't work.
I said that when I make a app myself from scratch, trying
to play flv-files it doesn't work.

But now I got it to work, though it works with .res files, just like in the samples, but I dont want it to work with .res files but simply with tmemorystream or tfilestream.
Please read my question again, there's all the info.

How can I simply play a flv file with only a tmemorystream or tfilestream
without using .res files? (because I need to get the swf's and flv's from a database field)

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

Postby Softanics » Thu Apr 26, 2007 7:39 am

flegel wrote:How can I simply play a flv file with only a tmemorystream or tfilestream
without using .res files? (because I need to get the swf's and flv's from a database field)


Sample8_Streaming demonstrates how to load FLV from a stream.

In a few words:

1. Set a global handler:

Code: Select all

FlashPlayerControl.SetGlobalOnLoadExternalResourceHandlerEx(ContentProvider);
...
procedure ContentProvider(const URL: string; Stream: TStream; out bHandled: Boolean);
...
end;


2. You load a movie.

3. Your movie loads a FLV using a full path, e.g. "http://flv/1.flv", f-in-box calls ContentProvider. In ContentProvider provide content of the flv:

Code: Select all

procedure TMainForm.ContentProvider(const URL: string; Stream: TStream; out bHandled: Boolean);
begin
  if URL = 'http://flv/1.flv' then
  begin
    Stream.Write ( ... ); // you provide a flv content here, in your case just copy from your TStream to Stream

    bHandled := true;
  end;
end;


If your FLV is a big, you can create a separate thread that writes to Stream, but don't forget to use Synchronize (see Sample8_Streaming) in this case.
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 9 guests