My Project
|
an instance of flash player. More...
#include <FlashTextureManager.h>
Public Types | |
typedef boost::shared_ptr< boost::thread > | Boost_Thread_ptr_type |
Public Member Functions | |
CFlashPlayer (int nFlashPlayerIndex) | |
bool | IsFree () |
whether the current player is free to load a new movie. More... | |
void | LoadMovie (const char *filename) |
load a movie by file name, it can be URL, a virtual file, a file, or a resource | |
void | PutFlashVars (const char *args) |
put flash variables. More... | |
const char * | CallFlashFunction (const char *sFunc) |
[ ActionScript ] import flash.external. More... | |
void | SetFlashReturnValue (const char *sResult) |
This function is called from NPL script to set the return value of an NPL function which can be called by the flash external interface call. More... | |
const char * | GetFlashReturnValue () |
get flash return value | |
void | UnloadMovie () |
unload current movie. More... | |
void | InvalidateDeviceObjects () |
release d3d texture. More... | |
void | RenderFrameMove (float fCurTime) |
called each render frame move, it may unload time out movies and force flash window to update itself More... | |
bool | GetTextureInfo (int *width, int *height) |
get texture info More... | |
LRESULT | SendMessage (UINT Msg, WPARAM wParam, LPARAM lParam) |
send a windows message to the inner flash player window. More... | |
LRESULT | PostMessage (UINT Msg, WPARAM wParam, LPARAM lParam) |
post a windows message to the inner flash player window. More... | |
const char * | GetFileName () |
get the movie file name. More... | |
int | GetIndex () |
get unique index of this flash player . More... | |
bool | IsWindowMode () |
whether this player is using a real win32 window for display. More... | |
void | SetWindowMode (bool bIsWindowMode) |
set whether this player is using a real win32 window for display. More... | |
void | MoveWindow (int x, int y, int width, int height, bool bRepaint=true) |
move or resize the window. More... | |
void | OnSizeChange () |
this function is called by ParaEngineApp whenever the window size is changed. More... | |
void | SetWindowVisible (bool bVisible) |
show or hide the window. More... | |
void | Repaint () |
repaint all window-mode flash window. More... | |
void | SetFocus () |
this can be called from any thread | |
HWND | GetWindowHandle () |
get the window handle if any. More... | |
void | UpdatePixelsBuffer () |
copy the current flash window client area to a memory buffer in system memory (m_lpPixels). More... | |
HRESULT | StartWindowThread () |
create the default win32 windows for rendering. More... | |
void | DefaultWinThreadProc () |
bool | MsgProcCustom (UINT message, WPARAM wParam, LPARAM lParam) |
process WM_USER messages | |
bool | PostWinThreadMessage (UINT message, WPARAM wParam, LPARAM lParam) |
post a WM_USER message to the window thread. More... | |
bool | SetParentWindow (HWND hWnd) |
this function is called, whenever the associated main parent window changes. More... | |
bool | HasFocus () |
if the flash window has focus. More... | |
LPDIRECT3DTEXTURE9 | GetTexture () |
get the texture. | |
Public Attributes | |
string | m_filename |
file name that the current texture is associated with. | |
float | m_fTimeOut |
if a flash player is never used for this number of time, it will be deleted. | |
float | m_fLastUsedTime |
last time the GetTexture() is called. | |
int | m_nFlashPlayerIndex |
index of this flash player | |
LPDIRECT3DTEXTURE9 | m_pTexture |
dynamic d3d texture | |
D3DFORMAT | m_TextureFormat |
bool | m_bUseDynamicTextures |
bool | m_bTextureUpdatedThisFrame |
whether the texture has been update in this rendering frame. More... | |
bool | m_bFree |
whether the current player is free. | |
bool | m_bTransparent |
There are two modes of rendering are supported: More... | |
HWND | m_hwndFlashPlayerControl |
flash control handle | |
int | m_nX |
int | m_nY |
int | m_nWidth |
int | m_nHeight |
int | m_nBufWidth |
int | m_nBufHeight |
int | m_nTextureWidth |
int | m_nTextureHeight |
int | m_nWindowX |
int | m_nWindowY |
int | m_nWindowWidth |
int | m_nWindowHeight |
DWORD * | m_lpPixels |
LinearColor | m_backgroundColor |
bool | m_bNeedFlashUpdate |
this flag is set to true every frame move. and set to false when the flash image is saved to temp buffer | |
bool | m_bFlipVertical |
bool | m_bWindowMode |
if true, we use a real win32 window. More... | |
string | m_sFlashReturnValue |
Boost_Thread_ptr_type | m_win_thread |
ParaEngine::mutex | m_win_thread_mutex |
bool | m_bWindowCreated |
bool | m_bWinThreadMovieLoaded |
DWORD | m_dwWinThreadID |
string | m_sCurrentFlashFunc |
string | m_sCurrentFlashFuncResponse |
bool | m_bInFlashFunc |
bool | m_bHasFocus |
an instance of flash player.
const char* ParaEngine::CFlashPlayer::CallFlashFunction | ( | const char * | sFunc | ) |
[ ActionScript ] import flash.external.
*; ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);
function InternalFunction(str: string): string { TextArea1.text = str; return "The function was called successfully"; } [ C++ ] string res = CallFlashFunction("<invoke name=\"CallMeFromApplication" returntype="xml"><arguments><string>Some text for FlashPlayerControl</string></arguments></invoke>");
res | result is returned as a string. |
Please note that the return value must be explicitly set in the NPL script, by calling SetFlashReturnValue() function. Otherwise empty string is returned.
[Security alert]: must be run in sand-box environment or there is a security here. Plus this function must be called from the same thread as ParaEngine main thread.
const char* ParaEngine::CFlashPlayer::GetFileName | ( | ) |
get the movie file name.
|
inline |
get unique index of this flash player .
bool ParaEngine::CFlashPlayer::GetTextureInfo | ( | int * | width, |
int * | height | ||
) |
get texture info
width | [out] |
height | [out] |
HWND ParaEngine::CFlashPlayer::GetWindowHandle | ( | ) |
get the window handle if any.
bool ParaEngine::CFlashPlayer::HasFocus | ( | ) |
if the flash window has focus.
void ParaEngine::CFlashPlayer::InvalidateDeviceObjects | ( | ) |
release d3d texture.
|
inline |
whether the current player is free to load a new movie.
|
inline |
whether this player is using a real win32 window for display.
void ParaEngine::CFlashPlayer::MoveWindow | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
bool | bRepaint = true |
||
) |
move or resize the window.
void ParaEngine::CFlashPlayer::OnSizeChange | ( | ) |
this function is called by ParaEngineApp whenever the window size is changed.
We usually needs to reposition all flash windows according to the new size.
LRESULT ParaEngine::CFlashPlayer::PostMessage | ( | UINT | Msg, |
WPARAM | wParam, | ||
LPARAM | lParam | ||
) |
post a windows message to the inner flash player window.
in most cases: we will forward mouse and key messages to the flash player using this function.
bool ParaEngine::CFlashPlayer::PostWinThreadMessage | ( | UINT | message, |
WPARAM | wParam, | ||
LPARAM | lParam | ||
) |
post a WM_USER message to the window thread.
void ParaEngine::CFlashPlayer::PutFlashVars | ( | const char * | args | ) |
put flash variables.
This function must be loaded before a flash movie is loaded.
args | such as "company=http://paraengine.com" |
void ParaEngine::CFlashPlayer::RenderFrameMove | ( | float | fCurTime | ) |
called each render frame move, it may unload time out movies and force flash window to update itself
fCurTime | Elapsed Time in seconds |
void ParaEngine::CFlashPlayer::Repaint | ( | ) |
repaint all window-mode flash window.
in case of full screen render, we may need to repaint when the background scene finished.
LRESULT ParaEngine::CFlashPlayer::SendMessage | ( | UINT | Msg, |
WPARAM | wParam, | ||
LPARAM | lParam | ||
) |
send a windows message to the inner flash player window.
in most cases: we will forward mouse and key messages to the flash player using this function.
void ParaEngine::CFlashPlayer::SetFlashReturnValue | ( | const char * | sResult | ) |
bool ParaEngine::CFlashPlayer::SetParentWindow | ( | HWND | hWnd | ) |
this function is called, whenever the associated main parent window changes.
Internally, we just call win32 function SetParent to change any already created flash windows.
void ParaEngine::CFlashPlayer::SetWindowMode | ( | bool | bIsWindowMode | ) |
set whether this player is using a real win32 window for display.
Default to false.
void ParaEngine::CFlashPlayer::SetWindowVisible | ( | bool | bVisible | ) |
show or hide the window.
HRESULT ParaEngine::CFlashPlayer::StartWindowThread | ( | ) |
create the default win32 windows for rendering.
and assigning to m_hWnd. window is created in another thread. Since windows uses single threaded apartment, the window procedure should also be in that thread.
void ParaEngine::CFlashPlayer::UnloadMovie | ( | ) |
unload current movie.
However d3d texture and the flash player window are not released for reuse.
void ParaEngine::CFlashPlayer::UpdatePixelsBuffer | ( | ) |
copy the current flash window client area to a memory buffer in system memory (m_lpPixels).
One may need to call Repaint() prior to this call to force flash window to update itself first.
bool ParaEngine::CFlashPlayer::m_bTextureUpdatedThisFrame |
whether the texture has been update in this rendering frame.
if there are multiple calls to GetTexture() in the same rendering frame, we will only copy texture once.
bool ParaEngine::CFlashPlayer::m_bTransparent |
There are two modes of rendering are supported:
bool ParaEngine::CFlashPlayer::m_bWindowMode |
if true, we use a real win32 window.