Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Using Macromedia Flash inside my application


Using Macromedia Flash inside my application

Postby drgoldie » Jan 27, 2005 @ 12:42pm

i need to embed macromedia flash movies into my application (preferably rendering onto an opengl|es texture, so i need pixel buffer access).

i saw that there is an application called FlashAssist (http://www.antmobile.com) which is a stand-alone viewer for flash movies using the standard active-x flash plugin. i tried to contact the author but got no reply.

does anybody know where i can find information on doing this?

thanks,
Daniel
drgoldie
pm Member
 
Posts: 330
Joined: Jan 10, 2003 @ 10:46am
Location: Vienna


Postby sponge » Jan 27, 2005 @ 2:40pm

Can't say I know the method, however I'm moderately sure that it doesn't do much more than embed a HTML control - i.e. rendering into an OGLES texture would be impractical if not impossible.
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby Dan East » Jan 27, 2005 @ 3:00pm

Here's the MFC based wrapper I wrote for the control:

FlashInterface.h:
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
#include <Oaidl.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlwin.h>
#import "flash.dll" raw_interfaces_only

const GUID LIBID_ShockwaveFlashObjects = {0xD27CDB6B, 0xAE6D,
0x11CF,{ 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };
const GUID IID_IShockwaveFlash = {0xD27CDB6C, 0xAE6D, 0x11CF,{ 0x96,
0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };
const GUID DIID_DShockwaveFlashEvents = {0xD27CDB6D, 0xAE6D,
0x11CF,{ 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };
const GUID CLSID_ShockwaveFlash = {0xD27CDB6E, 0xAE6D, 0x11CF,{ 0x96,
0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };
const GUID CLSID_FlashProp = {0x1171A62F, 0x05D2, 0x11D1,{ 0x83, 0xFC,
0x00, 0xA0, 0xC9, 0x08, 0x9C, 0x5A} };
const GUID IID_IFlashFactory = {0xD27CDB70, 0xAE6D, 0x11CF,{ 0x96,
0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };
const GUID IID_IFlashObjectInterface = {0xD27CDB72, 0xAE6D, 0x11CF,{
0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };
const GUID IID_IDispatchEx = {0xA6EF9860, 0xC720, 0x11D0,{ 0x93, 0x37,
0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9} };
const GUID IID_IServiceProvider = {0x6D5140C1, 0x7436, 0x11CE,{ 0x80,
0x34, 0x00, 0xAA, 0x00, 0x60, 0x09, 0xFA} };
const GUID CLSID_FlashObjectInterface = {0xD27CDB71, 0xAE6D,
0x11CF,{ 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} };


class CAxFlashWindow :
    public CWindowImpl<CAxFlashWindow,CAxWindow>,
    public CComPtr<ShockwaveFlashObjects::IShockwaveFlash>
{
public:
    DECLARE_WND_SUPERCLASS(_T("CAxFlashWindow"), CAxWindow::GetWndClassName());
    CAxFlashWindow();
    virtual ~CAxFlashWindow();

    HWND Create(HWND hWndParent,
            RECT& rcPos, LPCTSTR szWindowName = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0,
            UINT nID = 0, LPVOID lpCreateParam = NULL);

    LRESULT OnDestroy(UINT, WPARAM, LPARAM, BOOL&);

    BEGIN_MSG_MAP(CAxFlashWindow)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
    END_MSG_MAP()
};
48 lines; 20 keywds; 113 nums; 229 ops; 2 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


FlashInterface.c:
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
#include "stdafx.h"
#include "flashinterface.h"


// AtlAxWinInit is implemented in Atl.dll
 #pragma comment(lib, "atlce300.lib")
 #include <atldef.h>
 #define _ATL_DLL_IMPL
 #include <atliface.h>


CAxFlashWindow::CAxFlashWindow(){};
CAxFlashWindow:: ~CAxFlashWindow(){
    p = NULL;
}

HWND CAxFlashWindow::Create(HWND hWndParent,
        RECT& rcPos, LPCTSTR szWindowName,
        DWORD dwStyle, DWORD dwExStyle,
        UINT nID, LPVOID lpCreateParam)
{

    AtlAxWinInit();

    CWindowImpl<CAxFlashWindow, CAxWindow>::
        Create(hWndParent, rcPos, szWindowName, dwStyle, dwExStyle, nID, lpCreateParam);

    if (m_hWnd) {
        LPOLESTR clsid = NULL;
        StringFromCLSID(CLSID_ShockwaveFlash, &clsid);
        HRESULT hResult;
        hResult=CreateControl(clsid);
        if (hResult==E_FAIL)
            AfxMessageBox(_T("CreateControl failed"));
        CoTaskMemFree(clsid);
        ShockwaveFlashObjects::IShockwaveFlash *flash;
        hResult=QueryControl(IID_IShockwaveFlash, (void**)&flash);
        if (hResult==E_FAIL)
            AfxMessageBox(_T("QueryControl failed"));

        p = flash;
    }

    return m_hWnd;
}

LRESULT CAxFlashWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&){
    PostQuitMessage(0);
    return 0;
}
50 lines; 12 keywds; 2 nums; 123 ops; 5 strs; 1 coms    Syntactic Coloring v0.4 - Dan East  


Example usage:
Code: Select all






CAxFlashWindow flash;
HWND hWnd=flash.Create(hParent, rect, NULL, WS_CHILD|WS_VISIBLE);
if (!hWnd)
     //Failed
flash.p->put_Movie(_T("Something.swf"));
flash.p->Play();
6 lines; 1 keywds; 0 nums; 27 ops; 1 strs; 1 coms    Syntactic Coloring v0.4 - Dan East  


I have no idea why no-one has provided the code for utilizing the control on Windows CE. I searched for quite a while and couldn't find anything. You'd think Macromedia would have at least provided an example. I guess the few people that have figured it out are selling a product so they didn't release any source.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby drgoldie » Jan 27, 2005 @ 3:40pm

hi Dan,

thanks a lot for that code.
i'll try how far i get with this.

i also don't understand why Macromedia obviously has no interest in people using their controls. i downloaded the Flash PocketPC SDK, but it contains nothing more than just some information on how to create PocketPC fitting content...

Daniel
drgoldie
pm Member
 
Posts: 330
Joined: Jan 10, 2003 @ 10:46am
Location: Vienna


Postby drgoldie » Feb 9, 2005 @ 5:17pm

hi Dan,

i did not have a chance to test your code until now. unfortunately i've never used ATL and ran into problems:

i started with creating a std windows-ce application (no MFC, no ATL)

"CComModule _Module" is missing, i just created one in my main .cpp file. i don't know if this was correct.

doing so everything compiles fine but it simply does not work. all the code i can step into seems to run fine.

what i don't understand is:
where is the code for

flash.p->put_Movie(_T("moviename.swf"));
flash.p->Play();

comming from?
i assume that it is somehow created as a template but how does this mechanism work and how can i find out why this code does not work?

where can i find documentation about the class which flash.p is an instance of?

i also tried creating an ATL application or DLL but failed doing so (ATL is really a biest)...

thanks,
Daniel
drgoldie
pm Member
 
Posts: 330
Joined: Jan 10, 2003 @ 10:46am
Location: Vienna


Postby Dan East » Feb 9, 2005 @ 9:29pm

All the complex mess that is the ActiveX interface is handled by the ATL framework. I have no idea what all goes on behind the scenes to dynamically access class members (which is the whole purpose of COM / ActiveX). Several years ago I did some straight C++ coding to access COM but it was pretty tedious.

Maybe you can find some generic code for accessing ActiveX without ATL / MFC, if you really want to avoid it. Every Windows CE device ever made has the MFC and ATL dlls in rom, so there's no big reason to stay away from it. By utilizing and ActiveX control in the first place you're binding yourself to Microsoft platforms.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby drgoldie » Feb 9, 2005 @ 10:40pm

i'd just like to use that flash plugin...
i have no other reason to use ATL nor did i ever have one yet. i usually don't write that much windows specific code.

well, thanks anyway,
Daniel
drgoldie
pm Member
 
Posts: 330
Joined: Jan 10, 2003 @ 10:46am
Location: Vienna


Postby ericb » Jul 27, 2005 @ 1:15am

This is a great post, took me quite some time to figure it out as well, and your solution is much cleaner, but, your class doesn't sink events, like FSCommand(), OnReadyStateChange(), etc...
This could be important in some cases, and is (relatively) easy to add.

Also-----I'm not sure if you are aware of this, or, if the behavior is different on your PPC devices, but, on mine, LoadMovie() and put_Movie() don't work for movies on the filesystem. I had to embed a tiny webserver inside the (same) application that hosts the flash content, and, serve the content to the flash via http://localhost:xxx/yyyy. Although seemingly overkill, I can do some cool stuff: single-file CE flash projectors, something that is not possible with free tools (and from what I can tell, not even with the commercial ones out there).

Cheers,

-E
ericb
pm Member
 
Posts: 1
Joined: Jul 27, 2005 @ 1:13am


Postby hm » Jul 27, 2005 @ 3:01pm

drgoldie wrote:i'd just like to use that flash plugin...
i have no other reason to use ATL nor did i ever have one yet. i usually don't write that much windows specific code.

well, thanks anyway,
Daniel

Daniel, try to get a copy of Richard Grimes "ATL COM Programmer's Reference" or Rector & Brent's "ATL Internals" from your library. I concur with Dan that it's probably much easier to understand those handful of templates/macros in a day or so than trying to write this wrapper yourself (unless you can find a generic non-MFC/non-ATL wrapper on the net). The problem is COM-*control*, so all different callbacks and notifications back and forth between the control and your app need to be wired up. Without further information about the control you have to assume worst case (= generic wrapper), and that's where the ATL comes in handy.

- HM
User avatar
hm
pm Member
 
Posts: 201
Joined: Dec 28, 2003 @ 8:47pm
Location: Seattle, WA


Postby drgoldie » Aug 3, 2005 @ 10:31pm

the problem with wrapping the pocket ie plugin version is that one has only minimal control over the flash movie.

so i ported an open source flash player (gameswf) to the pocketpc, which was just a few hours of work. it now runs fine with opengl es but not very fast. at least i have perfect integration into my 3d apps...

Daniel
drgoldie
pm Member
 
Posts: 330
Joined: Jan 10, 2003 @ 10:46am
Location: Vienna


Postby casafurtado » Jul 26, 2006 @ 10:55am

You can open a local flash animation but you have to pass a valid local file url like

myFlash->LoadMovie(0, CComBSTR("file://\\test.swf"));
casafurtado
pm Member
 
Posts: 2
Joined: Jul 26, 2006 @ 10:51am


Postby casafurtado » Jul 26, 2006 @ 11:01am

Note that IShockwaveFlash interface is different on PC and PDA

PC :

struct __declspec(uuid("d27cdb6c-ae6d-11cf-96b8-444553540000"))
IShockwaveFlash : IDispatch
{
//
// Raw methods provided by interface
//

virtual HRESULT __stdcall get_ReadyState (
/*[out,retval]*/ long * pVal ) = 0;
virtual HRESULT __stdcall get_TotalFrames (
/*[out,retval]*/ long * pVal ) = 0;
virtual HRESULT __stdcall get_Playing (
/*[out,retval]*/ VARIANT_BOOL * pVal ) = 0;
virtual HRESULT __stdcall put_Playing (
/*[in]*/ VARIANT_BOOL pVal ) = 0;

PDA :

struct __declspec(uuid("d27cdb6c-ae6d-11cf-96b8-444553540000"))
IShockwaveFlash : IDispatch
{
//
// Raw methods provided by interface
//

virtual HRESULT __stdcall LoadMovie (
/*[in]*/ int layer,
/*[in]*/ BSTR url ) = 0;
virtual HRESULT __stdcall Play ( ) = 0;
virtual HRESULT __stdcall StopPlay ( ) = 0;
virtual HRESULT __stdcall Stop ( ) = 0;

That's why I am using the following lines to generate flash headers

#ifdef WINCE
// copy flash.dll from your PDA Windows/macromedia
// directory to your project include directory
#import "flash.dll" rename("IDispatchEx","My_IDispatchEx") no_namespace raw_interfaces_only
#else
#import "PROGID:ShockwaveFlash.ShockwaveFlash" rename("IDispatchEx","My_IDispatchEx") no_namespace raw_interfaces_only
#endif
casafurtado
pm Member
 
Posts: 2
Joined: Jul 26, 2006 @ 10:51am


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum