VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_inplacewnd(NULL),
+ _videownd(NULL),
_p_class(p_class),
_i_ref(1UL),
_i_codepage(CP_ACP),
_b_usermode(TRUE),
- _bstr_mrl(NULL),
- _b_autoplay(TRUE),
- _b_autoloop(FALSE),
- _b_visible(TRUE),
- _b_mute(FALSE),
_i_vlc(0)
{
p_class->AddRef();
// default picure
_p_pict = p_class->getInPlacePict();
- // set default/preferred size (320x240) pixels in HIMETRIC
- HDC hDC = CreateDevDC(NULL);
- _extent.cx = 320;
- _extent.cy = 240;
- HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
- DeleteDC(hDC);
+ // make sure that persistable properties are initialized
+ onInit();
};
VLCPlugin::~VLCPlugin()
{
if( 0 == _i_vlc )
{
- _i_vlc = VLC_Create();
- if( _i_vlc < 0 )
- {
- _i_vlc = 0;
- return E_FAIL;
- }
-
- /*
- ** default initialization options
- */
- char *ppsz_argv[10] = { "vlc", "-vv" };
- int ppsz_argc = 2;
-
- HKEY h_key;
- DWORD i_type, i_data = MAX_PATH + 1;
- char p_data[MAX_PATH + 1];
- if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
- 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
- {
- if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
- (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
- {
- if( i_type == REG_SZ )
- {
- strcat( p_data, "\\vlc" );
- ppsz_argv[0] = p_data;
- }
- }
- RegCloseKey( h_key );
- }
-
-#if 0
- ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
-#endif
-
- if( IsDebuggerPresent() )
- {
- /*
- ** VLC default threading mechanism is designed to be as compatible
- ** with POSIX as possible, however when debugged on win32, threads
- ** lose signals and eventually VLC get stuck during initialization.
- ** threading support can be configured to be more debugging friendly
- ** but it will be less compatible with POSIX.
- ** This is done by initializing with the following options
- */
- ppsz_argv[ppsz_argc++] = "--fast-mutex";
- ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
- }
+ // initialize persistable properties
+ _bstr_mrl = NULL;
+ _b_autoplay = TRUE;
+ _b_autoloop = FALSE;
+ _b_visible = TRUE;
+ _b_mute = FALSE;
+ _i_volume = 50;
+ // set default/preferred size (320x240) pixels in HIMETRIC
+ HDC hDC = CreateDevDC(NULL);
+ _extent.cx = 320;
+ _extent.cy = 240;
+ HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
+ DeleteDC(hDC);
- if( VLC_Init(_i_vlc, ppsz_argc, ppsz_argv) )
- {
- VLC_Destroy(_i_vlc);
- _i_vlc = 0;
- return E_FAIL;
- }
return S_OK;
}
return CO_E_ALREADYINITIALIZED;
HRESULT VLCPlugin::onLoad(void)
{
- if( _b_mute )
- VLC_VolumeMute(_i_vlc);
-
if( SysStringLen(_bstr_mrl) > 0 )
{
/*
}
pClientSite->Release();
}
+ }
+ setDirty(FALSE);
+ return S_OK;
+};
+
+HRESULT VLCPlugin::onRun(void)
+{
+ if( ! isRunning() )
+ {
+ _i_vlc = VLC_Create();
+ if( _i_vlc < 0 )
+ {
+ _i_vlc = 0;
+ return E_FAIL;
+ }
+
+ /*
+ ** default initialization options
+ */
+ char *ppsz_argv[10] = { "vlc", };
+ int ppsz_argc = 1;
+
+ HKEY h_key;
+ DWORD i_type, i_data = MAX_PATH + 1;
+ char p_data[MAX_PATH + 1];
+ if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
+ 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
+ {
+ if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
+ (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
+ {
+ if( i_type == REG_SZ )
+ {
+ strcat( p_data, "\\vlc" );
+ ppsz_argv[0] = p_data;
+ }
+ }
+ RegCloseKey( h_key );
+ }
+
+#if 1
+ ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
+#endif
+
+ // make sure plugin isn't affected with VLC single instance mode
+ ppsz_argv[ppsz_argc++] = "--no-one-instance";
+
+ // loop mode is a configuration option only
+ if( _b_autoloop )
+ ppsz_argv[ppsz_argc++] = "--loop";
+
+ if( IsDebuggerPresent() )
+ {
+ /*
+ ** VLC default threading mechanism is designed to be as compatible
+ ** with POSIX as possible, however when debugged on win32, threads
+ ** lose signals and eventually VLC get stuck during initialization.
+ ** threading support can be configured to be more debugging friendly
+ ** but it will be less compatible with POSIX.
+ ** This is done by initializing with the following options
+ */
+ ppsz_argv[ppsz_argc++] = "--fast-mutex";
+ ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
+ }
+
+ if( VLC_Init(_i_vlc, ppsz_argc, ppsz_argv) )
+ {
+ VLC_Destroy(_i_vlc);
+ _i_vlc = 0;
+ return E_FAIL;
+ }
+
+ VLC_VolumeSet(_i_vlc, _i_volume);
+
+ if( _b_mute )
+ VLC_VolumeMute(_i_vlc);
char *psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
if( NULL != psz_mrl )
{
// add default target to playlist
- char *cOptions[1];
- int cOptionsCount = 0;
-
- if( _b_autoloop )
- {
- cOptions[cOptionsCount++] = "loop";
- }
- VLC_AddTarget(_i_vlc, psz_mrl, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
+ VLC_AddTarget(_i_vlc, psz_mrl, NULL, 0, PLAYLIST_APPEND, PLAYLIST_END);
CoTaskMemFree(psz_mrl);
}
}
- setDirty(FALSE);
return S_OK;
};
case DISPID_AMBIENT_TOPTOBOTTOM:
break;
case DISPID_UNKNOWN:
- /*
- ** multiple property change, look up the ones we are interested in
- */
+ /*
+ ** multiple property change, look up the ones we are interested in
+ */
VariantInit(&v);
V_VT(&v) = VT_BOOL;
if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
{
- if( _i_vlc )
+ if( isInPlaceActive() )
+ {
+ onInPlaceDeactivate();
+ }
+ if( isRunning() )
{
int i_vlc = _i_vlc;
_i_vlc = 0;
- if( isInPlaceActive() )
- {
- onInPlaceDeactivate();
- }
vlcDataObject->onClose();
VLC_CleanUp(i_vlc);
if( getVisible() )
ShowWindow(_inplacewnd, SW_SHOW);
- /* set internal video width and height */
- vlc_value_t val;
- val.i_int = posRect.right-posRect.left;
- VLC_VariableSet(_i_vlc, "conf::width", val);
- val.i_int = posRect.bottom-posRect.top;
- VLC_VariableSet(_i_vlc, "conf::height", val);
-
- /* set internal video parent window */
- /* horrible cast there */
- val.i_int = reinterpret_cast<int>(_videownd);
- VLC_VariableSet(_i_vlc, "drawable", val);
-
- if( _b_usermode && _b_autoplay & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
+ if( _b_usermode )
{
- VLC_Play(_i_vlc);
- fireOnPlayEvent();
+ /* run vlc if not done already */
+ HRESULT result = onRun();
+ if( FAILED(result) )
+ return result;
+
+ /* set internal video width and height */
+ vlc_value_t val;
+ val.i_int = posRect.right-posRect.left;
+ VLC_VariableSet(_i_vlc, "conf::width", val);
+ val.i_int = posRect.bottom-posRect.top;
+ VLC_VariableSet(_i_vlc, "conf::height", val);
+
+ /* set internal video parent window */
+ /* horrible cast there */
+ val.i_int = reinterpret_cast<int>(_videownd);
+ VLC_VariableSet(_i_vlc, "drawable", val);
+
+ if( _b_autoplay & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
+ {
+ VLC_Play(_i_vlc);
+ fireOnPlayEvent();
+ }
}
return S_OK;
};
HRESULT VLCPlugin::onInPlaceDeactivate(void)
{
- VLC_Stop(_i_vlc);
- fireOnStopEvent();
+ if( isRunning() )
+ {
+ VLC_Stop(_i_vlc);
+ fireOnStopEvent();
+ }
DestroyWindow(_videownd);
_videownd = NULL;
if( isInPlaceActive() )
{
ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE);
+ if( fVisible )
+ InvalidateRect(_videownd, NULL, TRUE);
}
+ setDirty(TRUE);
firePropChangedEvent(DISPID_Visible);
}
};
+void VLCPlugin::setVolume(int volume)
+{
+ if( volume < 0 )
+ volume = 0;
+ else if( volume > 200 )
+ volume = 200;
+
+ if( volume != _i_volume )
+ {
+ _i_volume = volume;
+ if( isRunning() )
+ {
+ VLC_VolumeSet(_i_vlc, _i_volume);
+ }
+ setDirty(TRUE);
+ }
+};
+
void VLCPlugin::setFocus(BOOL fFocus)
{
if( fFocus )
<!--
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"
- width="640" height="480" id="vlc" events="True">
+<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"
+ width="640"
+ height="480"
+ id="vlc"
+ events="True">
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
+<param name="Volume" value="50" />
</OBJECT>
</TD></TR>
<TR><TD>
Insert MSComctlLib.Slider.2 activex control
-->
<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="Min" value="0" />
<param name="Max" value="0" />
<TR><TD colspan="2">
<INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause()'>
<INPUT type=button value="Stop" onClick='document.vlc.stop();'>
+
<INPUT type=button value=" << " onClick='document.vlc.playSlower();'>
<INPUT type=button value=" >> " onClick='document.vlc.playFaster();'>
-<INPUT type=button value="Mute" onClick='document.vlc.toggleMute();'>
+
<INPUT type=button value="Show" onClick='document.vlc.Visible = true;'>
<INPUT type=button value="Hide" onClick='document.vlc.Visible = false;'>
+
<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>
<SCRIPT LANGUAGE="JScript">
<!--
var sliderTimerId = 0;
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)
{
var timeHour = timeVal;