Page 1 of 1

LoadMovieFromMemory did not work with vb..

Posted: Mon Sep 04, 2006 7:37 am
by mobildev
Hi I wrote these lines in vb and don't work..I want to load movie from memory..(I do not want to use resource files. I read bytes from a file and use that byte array.. functions are below.)

Const WM_USER As Long = &H400
Const FPCM_FIRST As Long = WM_USER + &H1000
Const FPCM_PUTMOVIEFROMMEMORY As Long = FPCM_FIRST + 2
Private Type sFPCPutMovieFromMemory
lpData As Long
dwSize As Long
End Type

Private Sub cmdCommand1_Click()

Dim MyFPCPutMovieFromMemory As sFPCPutMovieFromMemory
RegisterFlashWindowClass
Dim rc As Rect
GetClientRect hWnd, rc

hwndFlashPlayerControl = CreateWindowExA(0, WC_FLASH, "", WS_CHILD Or WS_VISIBLE, 20, 20, rc.Right - 50, rc.Bottom - 170, Me.hWnd, 0, 0, 0)

FPCSetEventListener hwndFlashPlayerControl, AddressOf FlashEventsListener, 0


Dim bytes() As Byte
bytes = ReadBytesFromFile("C:\Send_Get_Test.swf")

MyFPCPutMovieFromMemory.lpData = bytes
MyFPCPutMovieFromMemory.dwSize = UBound(bytes)
Call SendMessage(hwndFlashPlayerControl, FPCM_PUTMOVIEFROMMEMORY, 0, VarPtr(MyFPCPutMovieFromMemory))

End Sub

Re: LoadMovieFromMemory did not work with vb..

Posted: Mon Sep 04, 2006 12:02 pm
by Softanics
Thank you for your question.

mobildev wrote:MyFPCPutMovieFromMemory.lpData = bytes


Is it correct?...
May be you shoud use something like that ( http://support.microsoft.com/kb/199824/EN-US/ ):

Code: Select all

MyFPCPutMovieFromMemory.lpData = VarPtr(bytes(0))

Yes,...but?

Posted: Mon Sep 04, 2006 12:15 pm
by mobildev
Thanks. You are Right..I correct it and working now..

But In my computer; my sample and samples that I downloaded from your site has another problem:
I run the code, ok it is working. stop it, close form..and reRun project again and see an error(This happens not all time, sometimes happens.) And this error not has an explanation, I think it is an error that is about dll own functions..
( Maybe error is about UnregisterFlashWindowClass() func. )

Posted: Mon Sep 04, 2006 12:24 pm
by Softanics
I think the error is related with registration/unregistration flashplayercontrol window class. When you work in VB6, you run the project in VB6 process. So if you forget to unregister the window class, the next call of RegisterFlashWindowClass will fail. The best solution for that is to reopen the VB6 IDE.