Page 1 of 1

Problem reading flv file in a dll

Posted: Mon Jun 05, 2006 1:07 pm
by FrereDavid
Hi

I'm now trying to do the same thing with a flv file that I did with the swf file : read the flv file in my dll, get its frames and give the data buffer to my 3d engine.
But I'm not really aware of how this should work :
- I tried to use FPC_LoadMovie(hWnd,0,"e:\\movie.flv"); , my code goes into GlobalOnLoadExternalResourceHandler() where I copied the code from the Sample_1_SWF_FLV_Reader, but it doesn't seem to work, if I try to get the current frame of my hWnd I get a -1.
- I tried to use FPCPutMovieFromResource(hWnd, 0, _T("FLVPlayer"), _T("SWF")); as in the example, but my code never goes into GlobalOnLoadExternalResourceHandler(). Maybe it is a problem a ressource as the FLVPLAYER ressource is in the dll project, that is called by the 3d engine (the 3d engine should'nt know anything about how the flv is read and so should'nt have the ressource needed).

I don't know if I made my problem really understandable but I'd be happy to have any lead :)

Posted: Mon Jun 05, 2006 3:31 pm
by Softanics
Thank you for your question.

The component isn't able to play FLV itself. It means you should load a movie that loads and play flv. You can see how it's implemented in the demo projects. The 3rd argument of FPCPutMovieFromResource is hinstance of the module that contains the resource, if you pass zero it means that the component will try to find the resource in the EXE, not in the DLL. Another words, code should be something like that:

Code: Select all

FPCPutMovieFromResource(hWnd, GetModuleHandle(_T("your_cool_dll_name_here.dll")), _T("FLVPlayer"), _T("SWF"));

Posted: Mon Jun 05, 2006 3:53 pm
by FrereDavid
Ok thanks it works great ! I needed the GetModuleHandle of my dll :)

just another question, the flv I read stops at the end and I can't make it loop even with :

SFPCPutLoop PutLoop;
PutLoop.Loop = TRUE;
::SendMessage(hWnd,FPCM_PUT_LOOP,0, (LPARAM)&PutLoop);

Any suggestion ?

Posted: Mon Jun 05, 2006 4:49 pm
by Softanics
FrereDavid wrote:just another question, the flv I read stops at the end and I can't make it loop even with :

SFPCPutLoop PutLoop;
PutLoop.Loop = TRUE;
::SendMessage(hWnd,FPCM_PUT_LOOP,0, (LPARAM)&PutLoop);

Any suggestion ?


When flv is playing in a movie, you are really have the only frame. That's why Loop doesn't work in this case.
I think you should handle NetStream.onStatus in ActionScript and restart the video when info.code == NetStream.Play.Stop (see in the flash help). Hope it helps.

Posted: Tue Jun 06, 2006 8:35 am
by FrereDavid
Hi

Doesn't it mean that I should modify the FLVPlayer.swf that you provided in order to incroporate this loop feature ? If this is the case, is it possible you provide your fla so I can do this ?
I'm thinking of puting inside a variable that you can update to decide if the flv loops or not, I could provide you the new fla with this feature if you want it.

Posted: Tue Jun 06, 2006 10:51 am
by Softanics
Yes, you should modify fla provided with the demo.

Add this code:

Code: Select all

netStream.onStatus = function(info) {
   if (info.code == "NetStream.Play.Stop") {
      netStream.seek(0);
      netStream.play();
   }
}



That's all :)

Posted: Tue Jun 06, 2006 12:07 pm
by FrereDavid
ok sorry, I didn't see it was already there :P