Page 1 of 1

Play a flash movie stored in Access Database

Posted: Thu Jun 15, 2006 5:05 am
by fferdinan
The dll doesn't work when I try to load a swf from memory. The swf file is stored and recovered from Access Database, using DAO 3.8 and Visual Basic 6.0

This is code:

First Method:

Dim abAVI() As Byte
Dim Rs As DAO.Recordset
Dim lpData As Long
Dim FileSize as Long

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


Set Rs = oDatabase.OpenRecordset("Select Video From Data Where Id = 1")

abAVI = Rs("Video")

fileSize = UBound(abAVI) + 1

lpData = VarPtr(abAVI(0))

FPCLoadMovieFromMemory.layer = 0
FPCLoadMovieFromMemory.lpData = lpData
FPCLoadMovieFromMemory.dwSize = fileSize

SendMessageA_LoadMovieFromMemory hwndFlashPlayerControl, FPCM_LOADMOVIEFROMMEMORY, 0, FPCLoadMovieFromMemory







Second Method:

Dim abAVI() As Byte
Dim Rs As DAO.Recordset
Dim lpData As Long
Dim FileSize as Long
Dim hMem As Long


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

Set Rs = oDatabase.OpenRecordset("Select Video From Data Where Id = 1")

abAVI = Rs("Video")

fileSize = UBound(abAVI) + 1
hMem = GlobalAlloc(GMEM_MOVEABLE, fileSize)

lpData = GlobalLock(hMem)

CopyMemory ByVal lpData, abAVI(0), fileSize

FPCLoadMovieFromMemory.layer = 0
FPCLoadMovieFromMemory.lpData = lpData
FPCLoadMovieFromMemory.dwSize = fileSize

SendMessageA_LoadMovieFromMemory hwndFlashPlayerControl, FPCM_LOADMOVIEFROMMEMORY, 0, FPCLoadMovieFromMemory



Any method works, what is wrong?


Thanks in advance.

Note: Some obvious code has been omitted.

Posted: Thu Jun 15, 2006 7:53 am
by Softanics
Thank you for your question.

Could you (for testing) save this swf file from the database on the disk and try to see it using Internet Explorer?

Play a flash movie stored in Access Database

Posted: Thu Jun 15, 2006 5:36 pm
by fferdinan
Yes I saved the file (stored in the Database) and the it works correctly using the internet explorer.

You can get the same database here.

http://www.caribika.com/Data.mdb

It has a table: Videos and the table has two fields Id and Data, the Data field is where the swf is stored in binary format.

Re: Play a flash movie stored in Access Database

Posted: Thu Jun 15, 2006 6:48 pm
by Softanics
fferdinan wrote:You can get the same database here.

http://www.caribika.com/Data.mdb


I can't load this mdb into my MS Access 2003. I'm getting the error. Did you protect the mdb?

Posted: Thu Jun 15, 2006 6:50 pm
by Softanics
Are you sure that this line

CopyMemory ByVal lpData, abAVI(0), fileSize


is correct?

I'm not a guru of VB6 :) but... could you save to file from the lpData array (not from abAVI! )?

Play a flash movie stored in Access Database

Posted: Fri Jun 16, 2006 2:38 am
by fferdinan
Yeah, the line is correct.

lpData is a pointer where I gonna copy the data from the array abAVI(0)

I tried this line too, but the dll doesn't work

CopyMemory ByVal lpData, VarPtr(abAVI(0)), fileSize


Description:
CopyMemory [Memory Pointer To Copy], [Memory Pointer From Copy], [Size]


But doesn't work


I think that the same job in C++ doesn't work either. (Using DAO and MS Access)

May be a bug in the dll?

Re: Play a flash movie stored in Access Database

Posted: Fri Jun 16, 2006 7:49 am
by Softanics
How do you declare CopyMemory? This is a correct declaration:

Code: Select all

Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)


fferdinan wrote:I think that the same job in C++ doesn't work either. (Using DAO and MS Access)

May be a bug in the dll?


Could you download demo EXEs and try it?

If you can send me compilable project and database file it would be great.