Commit 2fbbe6d5 authored by Damien Fouilleul's avatar Damien Fouilleul

plugin.cpp, plugin.h: delayed initialization of VLC until activation in place in user mode only

    this allows the persistable properties to be fully loaded before initialization and allow
    for control to initialize faster in design mode. AUTOLOOP property now works properly
persistpropbag.cpp, vlccontrol.h: decoupled volume property from VLC so that value can be used
    without having VLC initialized
test.html: added volume control
parent bb48220f
...@@ -161,11 +161,10 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr ...@@ -161,11 +161,10 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
} }
} }
int i_vlc = _p_instance->getVLCObject();
V_VT(&value) = VT_I4; V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("volume"), &value, pErrorLog) ) if( S_OK == pPropBag->Read(OLESTR("volume"), &value, pErrorLog) )
{ {
VLC_VolumeSet(i_vlc, V_I4(&value)); _p_instance->setVolume(V_I4(&value));
VariantClear(&value); VariantClear(&value);
} }
return _p_instance->onLoad(); return _p_instance->onLoad();
...@@ -208,14 +207,10 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt ...@@ -208,14 +207,10 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt
pPropBag->Write(OLESTR("Visible"), &value); pPropBag->Write(OLESTR("Visible"), &value);
VariantClear(&value); VariantClear(&value);
int i_vlc = _p_instance->getVLCObject(); V_VT(&value) = VT_I4;
if( i_vlc ) V_I4(&value) = _p_instance->getVolume();
{ pPropBag->Write(OLESTR("Volume"), &value);
V_VT(&value) = VT_I4; VariantClear(&value);
V_I4(&value) = VLC_VolumeGet(i_vlc);
pPropBag->Write(OLESTR("Volume"), &value);
VariantClear(&value);
}
if( fClearDirty ) if( fClearDirty )
_p_instance->setDirty(FALSE); _p_instance->setDirty(FALSE);
......
This diff is collapsed.
...@@ -109,6 +109,9 @@ public: ...@@ -109,6 +109,9 @@ public:
}; };
inline BOOL getAutoLoop(void) { return _b_autoloop;}; inline BOOL getAutoLoop(void) { return _b_autoloop;};
void setVolume(int volume);
BOOL getVolume(void) { return _i_volume; };
void setVisible(BOOL fVisible); void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; }; BOOL getVisible(void) { return _b_visible; };
...@@ -172,6 +175,7 @@ public: ...@@ -172,6 +175,7 @@ public:
*/ */
HRESULT onInit(void); HRESULT onInit(void);
HRESULT onLoad(void); HRESULT onLoad(void);
HRESULT onRun(void);
HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect); HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
HRESULT onInPlaceDeactivate(void); HRESULT onInPlaceDeactivate(void);
HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID); HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
...@@ -222,19 +226,21 @@ private: ...@@ -222,19 +226,21 @@ private:
VLCPluginClass *_p_class; VLCPluginClass *_p_class;
ULONG _i_ref; ULONG _i_ref;
LPPICTURE _p_pict;
UINT _i_codepage; UINT _i_codepage;
BOOL _b_usermode; BOOL _b_usermode;
int _i_vlc;
RECT _posRect;
// persistable properties
BSTR _bstr_mrl; BSTR _bstr_mrl;
BOOL _b_autoplay; BOOL _b_autoplay;
BOOL _b_autoloop; BOOL _b_autoloop;
BOOL _b_visible; BOOL _b_visible;
BOOL _b_mute; BOOL _b_mute;
BOOL _b_dirty; BOOL _b_dirty;
int _i_vlc; int _i_volume;
SIZEL _extent; SIZEL _extent;
RECT _posRect; LPPICTURE _p_pict;
}; };
#endif #endif
......
...@@ -11,12 +11,17 @@ MRL: ...@@ -11,12 +11,17 @@ MRL:
<!-- <!--
Insert VideoLAN.VLCPlugin.1 activex control 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#Version=0,8,4,0" <OBJECT classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8"
width="640" height="480" id="vlc" events="True"> codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,4,0"
width="640"
height="480"
id="vlc"
events="True">
<param name="MRL" value="" /> <param name="MRL" value="" />
<param name="ShowDisplay" value="True" /> <param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" /> <param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" /> <param name="AutoPlay" value="False" />
<param name="Volume" value="50" />
</OBJECT> </OBJECT>
</TD></TR> </TD></TR>
<TR><TD> <TR><TD>
...@@ -24,7 +29,10 @@ Insert VideoLAN.VLCPlugin.1 activex control ...@@ -24,7 +29,10 @@ Insert VideoLAN.VLCPlugin.1 activex control
Insert MSComctlLib.Slider.2 activex control Insert MSComctlLib.Slider.2 activex control
--> -->
<OBJECT classid="clsid:F08DF954-8592-11D1-B16A-00C0F0283628" <OBJECT classid="clsid:F08DF954-8592-11D1-B16A-00C0F0283628"
width="540" height="20" id="slider" events="True"> width="540"
height="20"
id="slider"
events="True">
<param name="TickStyle" value="3" /> <param name="TickStyle" value="3" />
<param name="Min" value="0" /> <param name="Min" value="0" />
<param name="Max" value="0" /> <param name="Max" value="0" />
...@@ -37,19 +45,40 @@ Insert MSComctlLib.Slider.2 activex control ...@@ -37,19 +45,40 @@ Insert MSComctlLib.Slider.2 activex control
<TR><TD colspan="2"> <TR><TD colspan="2">
<INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause()'> <INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause()'>
<INPUT type=button value="Stop" onClick='document.vlc.stop();'> <INPUT type=button value="Stop" onClick='document.vlc.stop();'>
&nbsp;
<INPUT type=button value=" << " onClick='document.vlc.playSlower();'> <INPUT type=button value=" << " onClick='document.vlc.playSlower();'>
<INPUT type=button value=" >> " onClick='document.vlc.playFaster();'> <INPUT type=button value=" >> " onClick='document.vlc.playFaster();'>
<INPUT type=button value="Mute" onClick='document.vlc.toggleMute();'> &nbsp;
<INPUT type=button value="Show" onClick='document.vlc.Visible = true;'> <INPUT type=button value="Show" onClick='document.vlc.Visible = true;'>
<INPUT type=button value="Hide" onClick='document.vlc.Visible = false;'> <INPUT type=button value="Hide" onClick='document.vlc.Visible = false;'>
&nbsp;
<INPUT type=button value="Version" onClick='alert(document.vlc.VersionInfo);'> <INPUT type=button value="Version" onClick='alert(document.vlc.VersionInfo);'>
</TD></TR> <SPAN style="text-align:center">Volume:</SPAN>
<INPUT type=button value=" - " onClick='updateVolume(-10)'>
<SPAN id="volumeTextField" style="text-align: center">--</SPAN>
<INPUT type=button value=" + " onClick='updateVolume(+10)'>
<INPUT type=button value="Mute" onClick='document.vlc.toggleMute();'>
</TD>
</TR>
</TABLE> </TABLE>
<SCRIPT LANGUAGE="JScript"> <SCRIPT LANGUAGE="JScript">
<!-- <!--
var sliderTimerId = 0; var sliderTimerId = 0;
var sliderScrolling = false; var sliderScrolling = false;
document.onreadystatechange=onVLCStateChange;
function onVLCStateChange()
{
if( document.readyState == 'complete' )
{
updateVolume(0);
}
};
function updateVolume(deltaVol)
{
vlc.Volume += deltaVol;
volumeTextField.innerText = vlc.Volume+"%";
};
function formatTime(timeVal) function formatTime(timeVal)
{ {
var timeHour = timeVal; var timeHour = timeVal;
......
...@@ -288,25 +288,14 @@ STDMETHODIMP VLCControl::get_Volume(int *volume) ...@@ -288,25 +288,14 @@ STDMETHODIMP VLCControl::get_Volume(int *volume)
if( NULL == volume ) if( NULL == volume )
return E_POINTER; return E_POINTER;
int i_vlc = _p_instance->getVLCObject(); *volume = _p_instance->getVolume();
if( i_vlc ) return NOERROR;
{
*volume = VLC_VolumeGet(i_vlc);
return NOERROR;
}
*volume = 0;
return E_UNEXPECTED;
}; };
STDMETHODIMP VLCControl::put_Volume(int volume) STDMETHODIMP VLCControl::put_Volume(int volume)
{ {
int i_vlc = _p_instance->getVLCObject(); _p_instance->setVolume(volume);
if( i_vlc ) return NOERROR;
{
VLC_VolumeSet(i_vlc, volume);
return NOERROR;
}
return E_UNEXPECTED;
}; };
STDMETHODIMP VLCControl::toggleMute(void) STDMETHODIMP VLCControl::toggleMute(void)
......
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