Commit d2310f2a authored by Damien Fouilleul's avatar Damien Fouilleul

all: reworked ActiveX plugin, which now works properly with .NET (tested with...

all: reworked ActiveX plugin, which now works properly  with .NET (tested with Visual Basic Express 2005)
     added persistent properties such as MRL, AutoPlay, AutoLoop which allows a user to play a default target
     without programming.
parent a4fe07f8
......@@ -33,11 +33,14 @@ library AXVLC
interface IVLCControl;
dispinterface DVLCEvents;
enum VLCPlaylistMode {
enum VLCPlaylistMode
{
VLCPlayListInsert = 1,
VLCPlayListInsertAndGo = 9,
VLCPlayListReplace = 2,
VLCPlayListReplaceAndGo = 10,
VLCPlayListAppend = 4,
VLCPlayListGo = 8,
VLCPlayListAppendAndGo = 12,
VLCPlayListCheckInsert = 16
};
......@@ -45,16 +48,15 @@ library AXVLC
const int VLCPlayListEnd = -666;
// DISPID definitions
const int DISPID_Visible = 1;
const int DISPID_Playing = 2;
const int DISPID_Position = 3;
const int DISPID_Time = 4;
const int DISPID_Length = 5;
const int DISPID_Volume = 6;
const int DISPID_PlayEvent = 1;
const int DISPID_PauseEvent = 2;
const int DISPID_StopEvent = 3;
const int DISPID_Visible = 100;
const int DISPID_Playing = 101;
const int DISPID_Position = 102;
const int DISPID_Time = 103;
const int DISPID_Length = 104;
const int DISPID_Volume = 105;
const int DISPID_MRL = 106;
const int DISPID_AutoPlay = 107;
const int DISPID_AutoLoop = 108;
[
odl,
......@@ -64,8 +66,8 @@ library AXVLC
hidden,
oleautomation
]
interface IVLCControl : IDispatch {
interface IVLCControl : IDispatch
{
[id(DISPID_Visible), propget, bindable, helpstring("Shows or hides plugin.")]
HRESULT Visible([out, retval] VARIANT_BOOL* visible);
[id(DISPID_Visible), propput, bindable, helpstring("Shows or hides plugin.")]
......@@ -76,13 +78,11 @@ library AXVLC
HRESULT pause();
[helpstring("Stop playback.")]
HRESULT stop();
[id(DISPID_Playing), bindable, propget, helpstring("Specifies whether VLC is playing.")]
[id(DISPID_Playing), hidden, propget, helpstring("Returns whether VLC is playing.")]
HRESULT Playing([out, retval] VARIANT_BOOL* isPlaying);
[id(DISPID_Playing), bindable, propput, helpstring("Specifies whether VLC is playing.")]
HRESULT Playing([in] VARIANT_BOOL isPlaying);
[id(DISPID_Position), bindable, propget, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
[id(DISPID_Position), propget, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([out, retval] float* position);
[id(DISPID_Position), bindable, propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
[id(DISPID_Position), propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([in] float position);
[id(DISPID_Time), propget, helpstring("Specifies playback time relative to the start of current target in playlist.")]
HRESULT Time([out, retval] int* seconds);
......@@ -92,15 +92,15 @@ library AXVLC
HRESULT shuttle([in] int seconds);
[helpstring("Switch between normal and fullscreen video.")]
HRESULT fullscreen();
[id(DISPID_Length), bindable, propget, helpstring("Returns total length in seconds of current target in playlist, may be unknown.")]
[id(DISPID_Length), propget, hidden, helpstring("Returns total length in seconds of current target in playlist, may be unknown.")]
HRESULT Length([out, retval] int* seconds);
[helpstring("Increases playback speed, one of 1x, 2x, 4x, 8x.")]
HRESULT playFaster();
[helpstring("Decreases playback speed, one of 1x, 2x, 4x, 8x.")]
HRESULT playSlower();
[id(DISPID_Volume), bindable, propget, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
[id(DISPID_Volume), propget, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
HRESULT Volume([out, retval] int* volume);
[id(DISPID_Volume), bindable, propput, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
[id(DISPID_Volume), propput, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
HRESULT Volume([in] int volume);
[helpstring("Mute/unmute playback sound volume.")]
HRESULT toggleMute();
......@@ -126,24 +126,41 @@ library AXVLC
HRESULT playlistPrev();
[helpstring("Remove all items from playlist.")]
HRESULT playlistClear();
[propget, helpstring("Returns VLC Version.")]
[propget, hidden, helpstring("Returns VLC Version.")]
HRESULT VersionInfo([out, retval] BSTR* version);
[id(DISPID_MRL), propget, helpstring("Returns initial MRL in default playlist")]
HRESULT MRL([out, retval] BSTR* mrl);
[id(DISPID_MRL), propput, helpstring("Specifies initial MRL in default playlist")]
HRESULT MRL([in] BSTR mrl);
[id(DISPID_AutoPlay), propget, helpstring("Specifies whether default playlist is played on startup")]
HRESULT AutoPlay([out, retval] VARIANT_BOOL* autoplay);
[id(DISPID_AutoPlay), propput, helpstring("Returns whether default playlist is played on startup")]
HRESULT AutoPlay([in] VARIANT_BOOL autoplay);
[id(DISPID_AutoLoop), propget, helpstring("Specifies whether default playlist is looped")]
HRESULT AutoLoop([out, retval] VARIANT_BOOL* autoloop);
[id(DISPID_AutoLoop), propput, helpstring("Returns whether default playlist is looped")]
HRESULT AutoLoop([in] VARIANT_BOOL autoloop);
};
const int DISPID_PlayEvent = 100;
const int DISPID_PauseEvent = 101;
const int DISPID_StopEvent = 102;
[
uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
helpstring("Event interface for VLC control"),
hidden
]
dispinterface DVLCEvents {
dispinterface DVLCEvents
{
properties:
methods:
[id(DISPID_PlayEvent), helpstring("Playback in progress")]
void Play();
void play();
[id(DISPID_PauseEvent), helpstring("Playback has paused")]
void Pause();
void pause();
[id(DISPID_StopEvent), helpstring("Playback has stopped")]
void Stop();
void stop();
};
[
......@@ -151,7 +168,8 @@ library AXVLC
helpstring("VLC control"),
control
]
coclass VLCPlugin {
coclass VLCPlugin
{
[default] interface IVLCControl;
[default, source] dispinterface DVLCEvents;
};
......
No preview for this file type
......@@ -5,7 +5,7 @@
/* File created by MIDL compiler version 5.01.0164 */
/* at Tue May 10 21:24:51 2005
/* at Sun Aug 21 17:16:22 2005
*/
/* Compiler settings for axvlc.idl:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......
This diff is collapsed.
......@@ -192,18 +192,16 @@ HRESULT VLCDataObject::getMetaFileData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedi
SIZEL size = _p_instance->getExtent();
RECTL wBounds = { 0L, 0L, size.cx, size.cy };
LONG width = size.cx*GetDeviceCaps(hicTargetDev, LOGPIXELSX)/2540L;
LONG height = size.cy*GetDeviceCaps(hicTargetDev, LOGPIXELSY)/2540L;
pMetaFilePict->mm = MM_ANISOTROPIC;
pMetaFilePict->xExt = size.cx;
pMetaFilePict->yExt = size.cy;
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
SetMapMode(hdcMeta, MM_ANISOTROPIC);
SetWindowOrgEx(hdcMeta, 0, 0, NULL);
SetWindowExtEx(hdcMeta, width, height, NULL);
SetWindowExtEx(hdcMeta, size.cx, size.cy, NULL);
RECTL bounds = { 0L, 0L, width, height };
RECTL bounds = { 0L, 0L, size.cx, size.cy };
_p_instance->onDraw(pFormatEtc->ptd, hicTargetDev, hdcMeta, &bounds, &wBounds);
pMetaFilePict->hMF = CloseMetaFile(hdcMeta);
......@@ -230,10 +228,9 @@ HRESULT VLCDataObject::getEnhMetaFileData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pM
{
RECTL wBounds = { 0L, 0L, size.cx, size.cy };
LONG width = size.cx*GetDeviceCaps(hicTargetDev, LOGPIXELSX)/2540L;
LONG height = size.cy*GetDeviceCaps(hicTargetDev, LOGPIXELSY)/2540L;
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
RECTL bounds = { 0L, 0L, width, height };
RECTL bounds = { 0L, 0L, size.cx, size.cy };
_p_instance->onDraw(pFormatEtc->ptd, hicTargetDev, hdcMeta, &bounds, &wBounds);
pMedium->hEnhMetaFile = CloseEnhMetaFile(hdcMeta);
......@@ -279,6 +276,11 @@ STDMETHODIMP VLCDataObject::SetData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium,
return E_NOTIMPL;
};
/*void VLCDataObject::onDataChange(void)
{
_p_adviseHolder->SendOnDataChange(this, 0, 0);
};*/
void VLCDataObject::onClose(void)
{
_p_adviseHolder->SendOnDataChange(this, 0, ADVF_DATAONSTOP);
......
......@@ -96,7 +96,7 @@ static LPCTSTR TStrFromGUID(REFGUID clsid)
if( len > 0 )
{
clsidStr = (wchar_t *)CoTaskMemAlloc(len*sizeof(wchar_t));
WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len);
MultiByteToWideChar(CP_ACP, 0, oleStr, -1, pct_CLSID, len);
}
#endif
CoTaskMemFree(oleStr);
......
......@@ -23,8 +23,6 @@
#include "plugin.h"
#include "olecontrol.h"
#include "utils.h"
using namespace std;
STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI)
......@@ -45,12 +43,12 @@ STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg)
return E_NOTIMPL;
};
static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v)
STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)
{
HRESULT hr;
IOleObject *oleObj;
hr = instance.QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
hr = QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
if( SUCCEEDED(hr) )
{
IOleClientSite *clientSite;
......@@ -58,70 +56,11 @@ static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v
hr = oleObj->GetClientSite(&clientSite);
if( SUCCEEDED(hr) && (NULL != clientSite) )
{
hr = GetObjectProperty(clientSite, dispID, v);
_p_instance->onAmbientChanged(clientSite, dispID);
clientSite->Release();
}
oleObj->Release();
}
return hr;
};
STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)
{
switch( dispID )
{
case DISPID_AMBIENT_BACKCOLOR:
break;
case DISPID_AMBIENT_DISPLAYNAME:
break;
case DISPID_AMBIENT_FONT:
break;
case DISPID_AMBIENT_FORECOLOR:
break;
case DISPID_AMBIENT_LOCALEID:
break;
case DISPID_AMBIENT_MESSAGEREFLECT:
break;
case DISPID_AMBIENT_SCALEUNITS:
break;
case DISPID_AMBIENT_TEXTALIGN:
break;
case DISPID_AMBIENT_USERMODE:
break;
case DISPID_AMBIENT_UIDEAD:
break;
case DISPID_AMBIENT_SHOWGRABHANDLES:
break;
case DISPID_AMBIENT_SHOWHATCHING:
break;
case DISPID_AMBIENT_DISPLAYASDEFAULT:
break;
case DISPID_AMBIENT_SUPPORTSMNEMONICS:
break;
case DISPID_AMBIENT_AUTOCLIP:
break;
case DISPID_AMBIENT_APPEARANCE:
break;
case DISPID_AMBIENT_CODEPAGE:
VARIANT v;
VariantInit(&v);
V_VT(&v) = VT_I4;
if( SUCCEEDED(getAmbientProperty(*_p_instance, dispID, v)) )
{
_p_instance->setCodePage(V_I4(&v));
}
break;
case DISPID_AMBIENT_PALETTE:
break;
case DISPID_AMBIENT_CHARSET:
break;
case DISPID_AMBIENT_RIGHTTOLEFT:
break;
case DISPID_AMBIENT_TOPTOBOTTOM:
break;
default:
break;
}
return S_OK;
};
......
......@@ -28,18 +28,15 @@ using namespace std;
STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd)
{
if( NULL == pHwnd )
return E_INVALIDARG;
return E_POINTER;
*pHwnd = NULL;
if( _p_instance->isInPlaceActive() )
{
if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
return S_OK;
return E_FAIL;
}
*pHwnd = NULL;
return E_UNEXPECTED;
return E_FAIL;
};
STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable)
......
......@@ -30,18 +30,15 @@ using namespace std;
STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)
{
if( NULL == pHwnd )
return E_INVALIDARG;
return E_POINTER;
*pHwnd = NULL;
if( _p_instance->isInPlaceActive() )
{
if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
return S_OK;
return E_FAIL;
}
*pHwnd = NULL;
return E_UNEXPECTED;
return E_FAIL;
};
STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
......@@ -54,6 +51,7 @@ STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
if( _p_instance->isInPlaceActive() )
{
UIDeactivate();
_p_instance->onInPlaceDeactivate();
LPOLEOBJECT p_oleObject;
......@@ -85,26 +83,26 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
if( _p_instance->hasFocus() )
{
_p_instance->setFocus(FALSE);
}
LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
{
LPOLECLIENTSITE p_clientSite;
if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
{
LPOLECLIENTSITE p_clientSite;
if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release();
}
p_clientSite->Release();
p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release();
}
p_oleObject->Release();
p_clientSite->Release();
}
return S_OK;
p_oleObject->Release();
}
return S_OK;
}
return E_UNEXPECTED;
};
......
......@@ -37,8 +37,9 @@ _p_clientsite(NULL), _p_instance(p_instance)
VLCOleObject::~VLCOleObject()
{
SetClientSite(NULL);
Close(OLECLOSE_NOSAVE);
_p_advise_holder->Release();
SetClientSite(NULL);
};
STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
......@@ -48,8 +49,12 @@ STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
if( _p_instance->isRunning() )
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
}
return S_OK;
};
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
......@@ -115,6 +120,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
OLEINPLACEFRAMEINFO oleFrameInfo;
oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
{
lprcPosRect = &posRect;
......@@ -302,29 +308,16 @@ STDMETHODIMP VLCOleObject::IsUpToDate(void)
STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
{
if( NULL != pClientSite )
{
pClientSite->AddRef();
/*
** retrieve container ambient properties
*/
VARIANT v;
VariantInit(&v);
V_VT(&v) = VT_I4;
if( SUCCEEDED(GetObjectProperty(pClientSite, DISPID_AMBIENT_CODEPAGE, v)) )
{
_p_instance->setCodePage(V_I4(&v));
VariantClear(&v);
}
}
if( NULL != _p_clientsite )
_p_clientsite->Release();
_p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
if( NULL != pClientSite )
{
pClientSite->AddRef();
_p_instance->onAmbientChanged(pClientSite, DISPID_UNKNOWN);
}
return S_OK;
};
......
......@@ -45,59 +45,95 @@ STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
{
if( NULL == pPropBag )
return E_POINTER;
HRESULT hr = _p_instance->onInit();
if( FAILED(hr) )
return hr;
if( NULL == pPropBag )
return E_INVALIDARG;
VARIANT value;
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("mrl"), &value, pErrorLog) )
{
char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
if( NULL != src )
{
_p_instance->setSourceURL(src);
free(src);
}
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
else
{
char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
if( NULL != src )
/*
** try alternative syntax
*/
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
{
_p_instance->setSourceURL(src);
free(src);
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
else
{
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
{
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
}
VariantClear(&value);
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) )
{
_p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
{
_p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
SIZEL size = _p_instance->getExtent();
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("extentwidth"), &value, pErrorLog) )
{
size.cx = V_I4(&value);
VariantClear(&value);
}
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("extentheight"), &value, pErrorLog) )
{
_p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
size.cy = V_I4(&value);
VariantClear(&value);
}
_p_instance->setExtent(size);
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("autoloop"), &value, pErrorLog) )
{
_p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
{
_p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) )
......@@ -107,19 +143,81 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("visible"), &value, pErrorLog) )
{
_p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
{
_p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
int i_vlc = _p_instance->getVLCObject();
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("volume"), &value, pErrorLog) )
{
VLC_VolumeSet(i_vlc, V_I4(&value));
VariantClear(&value);
}
return _p_instance->onLoad();
};
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
{
if( NULL == pPropBag )
return E_POINTER;
return E_INVALIDARG;
VARIANT value;
VariantInit(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getAutoLoop()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("AutoLoop"), &value);
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getAutoPlay()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("AutoPlay"), &value);
VariantClear(&value);
SIZEL size = _p_instance->getExtent();
V_VT(&value) = VT_I4;
V_I4(&value) = size.cx;
pPropBag->Write(OLESTR("ExtentWidth"), &value);
V_I4(&value) = size.cy;
pPropBag->Write(OLESTR("ExtentHeight"), &value);
V_VT(&value) = VT_BSTR;
V_BSTR(&value) = SysAllocString(_p_instance->getMRL());
pPropBag->Write(OLESTR("MRL"), &value);
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getVisible()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("Visible"), &value);
VariantClear(&value);
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
V_VT(&value) = VT_I4;
V_I4(&value) = VLC_VolumeGet(i_vlc);
pPropBag->Write(OLESTR("Volume"), &value);
VariantClear(&value);
}
if( fClearDirty )
_p_instance->setDirty(FALSE);
return S_OK;
};
......
......@@ -37,31 +37,63 @@ STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStorage::IsDirty(void)
{
return S_FALSE;
return _p_instance->isDirty() ? S_OK : S_FALSE;
};
STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
{
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
{
if( NULL == pStg )
return E_POINTER;
return E_INVALIDARG;
return _p_instance->onInit();
LPSTREAM pStm = NULL;
HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Load(pStm);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
{
if( NULL == pStg )
return E_POINTER;
return E_INVALIDARG;
return S_OK;
if( fSameAsLoad && (S_FALSE == IsDirty()) )
return S_OK;
LPSTREAM pStm = NULL;
HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data",
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Save(pStm, fSameAsLoad);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)
......
This diff is collapsed.
......@@ -30,8 +30,8 @@ class VLCPersistStreamInit : public IPersistStreamInit
public:
VLCPersistStreamInit(VLCPlugin *p_instance) : _p_instance(p_instance) {};
virtual ~VLCPersistStreamInit() {};
VLCPersistStreamInit(VLCPlugin *p_instance);
virtual ~VLCPersistStreamInit();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
......@@ -63,6 +63,7 @@ public:
private:
VLCPlugin *_p_instance;
class VLCPropertyBag *_p_props;
};
#endif
......
This diff is collapsed.
......@@ -80,58 +80,109 @@ public:
STDMETHODIMP_(ULONG) Release(void);
/* custom methods */
HRESULT getTypeLib(LCID lcid, ITypeLib **pTL)
{ return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
HRESULT onInit(void);
HRESULT onLoad(void);
HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
HRESULT onClose(DWORD dwSaveOption);
/*
** persistant properties
*/
void setMRL(BSTR mrl)
{
SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(mrl);
setDirty(TRUE);
};
const BSTR getMRL(void) { return _bstr_mrl; };
inline void setAutoPlay(BOOL autoplay)
{
_b_autoplay = autoplay;
setDirty(TRUE);
};
inline BOOL getAutoPlay(void) { return _b_autoplay; };
inline void setAutoLoop(BOOL autoloop)
{
_b_autoloop = autoloop;
setDirty(TRUE);
};
inline BOOL getAutoLoop(void) { return _b_autoloop;};
BOOL isInPlaceActive(void);
HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
HRESULT onInPlaceDeactivate(void);
HWND getInPlaceWindow(void) const { return _inplacewnd; };
void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; };
// control size in HIMETRIC
inline void setExtent(const SIZEL& extent)
{
_extent = extent;
setDirty(TRUE);
};
const SIZEL& getExtent(void) { return _extent; };
// transient properties
inline void setMute(BOOL mute) { _b_mute = mute; };
inline void setPicture(LPPICTURE pict)
{
if( NULL != _p_pict )
_p_pict->Release();
if( NULL != pict )
_p_pict->AddRef();
_p_pict = pict;
};
inline LPPICTURE getPicture(void)
{
if( NULL != _p_pict )
_p_pict->AddRef();
return _p_pict;
};
BOOL hasFocus(void);
void setFocus(BOOL fFocus);
UINT getCodePage(void) { return _codepage; };
void setCodePage(UINT cp) { _codepage = cp; };
inline UINT getCodePage(void) { return _i_codepage; };
inline void setCodePage(UINT cp) { _i_codepage = cp; };
int getVLCObject(void) { return _i_vlc; };
inline BOOL isUserMode(void) { return _b_usermode; };
inline void setUserMode(BOOL um) { _b_usermode = um; };
// persistent control properties, may be overriden by HTML & javascript
void setSourceURL(const char *url) { _psz_src = strdup(url); };
void setAutoStart(BOOL autostart) { _b_autostart = autostart; };
void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };
void setMute(BOOL mute) { _b_mute = mute; };
void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; };
LPPICTURE getPicture(void) { if( NULL != _pict ) _pict->AddRef(); return _pict; };
// container events
inline BOOL isDirty(void) { return _b_dirty; };
inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return 0 != _i_vlc; };
// control geometry within container
RECT getPosRect(void) { return _posRect; };
inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
BOOL isInPlaceActive(void);
inline int getVLCObject(void) const { return _i_vlc; };
/*
** container events
*/
HRESULT onInit(void);
HRESULT onLoad(void);
HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
HRESULT onInPlaceDeactivate(void);
HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
HRESULT onClose(DWORD dwSaveOption);
void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
// control events
/*
** control events
*/
void freezeEvents(BOOL freeze);
void firePropChangedEvent(DISPID dispid);
void fireOnPlayEvent(void);
void fireOnPauseEvent(void);
void fireOnStopEvent(void);
// control size in HIMETRIC
const SIZEL& getExtent(void) { return _extent; };
void setExtent(const SIZEL& extent) { _extent = extent; };
// control geometry within container
RECT getPosRect(void) { return _posRect; };
// controlling IUnknown interface
LPUNKNOWN pUnkOuter;
......@@ -164,13 +215,15 @@ private:
VLCPluginClass *_p_class;
ULONG _i_ref;
LPPICTURE _pict;
UINT _codepage;
char *_psz_src;
BOOL _b_autostart;
BOOL _b_loopmode;
LPPICTURE _p_pict;
UINT _i_codepage;
BOOL _b_usermode;
BSTR _bstr_mrl;
BOOL _b_autoplay;
BOOL _b_autoloop;
BOOL _b_visible;
BOOL _b_mute;
BOOL _b_dirty;
int _i_vlc;
SIZEL _extent;
......
......@@ -13,9 +13,9 @@ Insert VideoLAN.VLCPlugin.1 activex control
-->
<OBJECT classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"
width="640" height="480" id="vlc" events="True">
<param name="Src" value="" />
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="Loop" value="False" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
</OBJECT>
</TD></TR>
......@@ -123,7 +123,7 @@ function doUpdate()
};
function doGo(targetURL)
{
var options = new Array(":input-repeat=1");
var options = new Array(":input-repeat=0");
document.vlc.addTarget(targetURL, options, 4+8, -666);
};
function doPlayOrPause()
......@@ -137,7 +137,7 @@ function doPlayOrPause()
document.vlc.play();
}
};
function vlc::play()
function vlc::Play()
{
if( ! sliderTimerId )
{
......@@ -145,7 +145,7 @@ function vlc::play()
}
onPlay();
};
function vlc::pause()
function vlc::Pause()
{
if( sliderTimerId )
{
......@@ -154,7 +154,7 @@ function vlc::pause()
}
onPause();
};
function vlc::stop()
function vlc::Stop()
{
if( sliderTimerId )
{
......
......@@ -40,7 +40,10 @@ char *CStrFromBSTR(int codePage, BSTR bstr)
char *buffer = (char *)CoTaskMemAlloc(mblen+1);
ZeroMemory(buffer, mblen+1);
if( WideCharToMultiByte(codePage, 0, bstr, len, buffer, mblen, NULL, NULL) )
{
buffer[mblen] = '\0';
return buffer;
}
}
}
return NULL;
......@@ -130,4 +133,29 @@ errReturn:
return hdc;
};
#define HIMETRIC_PER_INCH 2540
void DPFromHimetric(HDC hdc, LPPOINT pt, int count)
{
LONG lpX = GetDeviceCaps(hdc, LOGPIXELSX);
LONG lpY = GetDeviceCaps(hdc, LOGPIXELSY);
while( count-- )
{
pt->x = pt->x*lpX/HIMETRIC_PER_INCH;
pt->y = pt->y*lpY/HIMETRIC_PER_INCH;
++pt;
}
};
void HimetricFromDP(HDC hdc, LPPOINT pt, int count)
{
LONG lpX = GetDeviceCaps(hdc, LOGPIXELSX);
LONG lpY = GetDeviceCaps(hdc, LOGPIXELSY);
while( count-- )
{
pt->x = pt->x*HIMETRIC_PER_INCH/lpX;
pt->y = pt->y*HIMETRIC_PER_INCH/lpY;
++pt;
}
};
......@@ -36,6 +36,9 @@ extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v);
// properties
extern HDC CreateDevDC(DVTARGETDEVICE *ptd);
extern void DPFromHimetric(HDC hdc, LPPOINT pt, int count);
extern void HimetricFromDP(HDC hdc, LPPOINT pt, int count);
// enumeration
template<class T> class VLCEnum : IUnknown
......
......@@ -33,7 +33,35 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
{
if( dwAspect & DVASPECT_CONTENT )
{
_p_instance->onDraw(ptd, hicTargetDev, hdcDraw, lprcBounds, lprcWBounds);
if( NULL == lprcBounds )
return E_INVALIDARG;
BOOL releaseDC = FALSE;
SIZEL size = _p_instance->getExtent();
if( NULL == ptd )
{
hicTargetDev = CreateDevDC(NULL);
releaseDC = TRUE;
}
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
RECTL bounds = { 0L, 0L, size.cx, size.cy };
int sdc = SaveDC(hdcDraw);
SetMapMode(hdcDraw, MM_ANISOTROPIC);
SetWindowOrgEx(hdcDraw, 0, 0, NULL);
SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
OffsetViewportOrgEx(hdcDraw, lprcBounds->left, lprcBounds->top, NULL);
SetViewportExtEx(hdcDraw, lprcBounds->right-lprcBounds->left,
lprcBounds->bottom-lprcBounds->top, NULL);
_p_instance->onDraw(ptd, hicTargetDev, hdcDraw, &bounds, lprcWBounds);
RestoreDC(hdcDraw, sdc);
if( releaseDC )
DeleteDC(hicTargetDev);
return S_OK;
}
return E_NOTIMPL;
......
......@@ -126,26 +126,6 @@ STDMETHODIMP VLCControl::play(void)
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
if( ! _p_instance->isInPlaceActive() )
{
/*
** object has not yet been activated. try doing it by ourself
** if parent container is known
*/
LPOLEOBJECT p_oleobject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (LPVOID *)&p_oleobject)) )
{
LPOLECLIENTSITE p_clientsite;
if( SUCCEEDED(p_oleobject->GetClientSite(&p_clientsite)
&& (NULL != p_clientsite)) )
{
p_oleobject->DoVerb(OLEIVERB_INPLACEACTIVATE,
NULL, p_clientsite, 0, NULL, NULL);
p_clientsite->Release();
}
p_oleobject->Release();
}
}
VLC_Play(i_vlc);
_p_instance->fireOnPlayEvent();
return NOERROR;
......@@ -175,7 +155,7 @@ STDMETHODIMP VLCControl::stop(void)
return NOERROR;
}
return E_UNEXPECTED;
}
};
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
{
......@@ -192,26 +172,6 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
return E_UNEXPECTED;
};
STDMETHODIMP VLCControl::put_Playing(VARIANT_BOOL isPlaying)
{
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
if( VARIANT_FALSE == isPlaying )
{
if( VLC_IsPlaying(i_vlc) )
VLC_Stop(i_vlc);
}
else
{
if( ! VLC_IsPlaying(i_vlc) )
VLC_Play(i_vlc);
}
return NOERROR;
}
return E_UNEXPECTED;
};
STDMETHODIMP VLCControl::get_Position(float *position)
{
if( NULL == position )
......@@ -360,7 +320,7 @@ STDMETHODIMP VLCControl::toggleMute(void)
return E_UNEXPECTED;
};
STDMETHODIMP VLCControl::setVariable( BSTR name, VARIANT value)
STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
{
if( 0 == SysStringLen(name) )
return E_INVALIDARG;
......@@ -755,27 +715,26 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
int codePage = _p_instance->getCodePage();
char *cUri = CStrFromBSTR(codePage, uri);
char *cUri = CStrFromBSTR(CP_UTF8, uri);
if( NULL == cUri )
return E_OUTOFMEMORY;
int cOptionsCount;
char **cOptions;
if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) )
if( FAILED(createTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG;
if( VLC_SUCCESS <= VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position) )
{
hr = NOERROR;
if( mode & VLCPlayListGo )
if( mode & PLAYLIST_GO )
_p_instance->fireOnPlayEvent();
}
else
{
hr = E_FAIL;
if( mode & VLCPlayListGo )
if( mode & PLAYLIST_GO )
_p_instance->fireOnStopEvent();
}
......@@ -861,3 +820,49 @@ STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
return E_FAIL;
};
STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
{
if( NULL == mrl )
return E_POINTER;
*mrl = SysAllocString(_p_instance->getMRL());
return NOERROR;
};
STDMETHODIMP VLCControl::put_MRL(BSTR mrl)
{
_p_instance->setMRL(mrl);
return S_OK;
};
STDMETHODIMP VLCControl::get_AutoPlay(VARIANT_BOOL *autoplay)
{
if( NULL == autoplay )
return E_POINTER;
*autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
return S_OK;
};
STDMETHODIMP VLCControl::put_AutoPlay(VARIANT_BOOL autoplay)
{
_p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
return S_OK;
};
STDMETHODIMP VLCControl::get_AutoLoop(VARIANT_BOOL *autoloop)
{
if( NULL == autoloop )
return E_POINTER;
*autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
return S_OK;
};
STDMETHODIMP VLCControl::put_AutoLoop(VARIANT_BOOL autoloop)
{
_p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
return S_OK;
};
......@@ -64,7 +64,6 @@ public:
STDMETHODIMP pause(void);
STDMETHODIMP stop(void);
STDMETHODIMP get_Playing(VARIANT_BOOL *isPlaying);
STDMETHODIMP put_Playing(VARIANT_BOOL isPlaying);
STDMETHODIMP get_Position(float *position);
STDMETHODIMP put_Position(float position);
STDMETHODIMP get_Time(int *seconds);
......@@ -86,6 +85,12 @@ public:
STDMETHODIMP playlistPrev(void);
STDMETHODIMP playlistClear(void);
STDMETHODIMP get_VersionInfo(BSTR *version);
STDMETHODIMP get_MRL(BSTR *mrl);
STDMETHODIMP put_MRL(BSTR mrl);
STDMETHODIMP get_AutoLoop(VARIANT_BOOL *autoloop);
STDMETHODIMP put_AutoLoop(VARIANT_BOOL autoloop);
STDMETHODIMP get_AutoPlay(VARIANT_BOOL *autoplay);
STDMETHODIMP put_AutoPlay(VARIANT_BOOL autoplay);
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment