_b_visible = TRUE;
_b_mute = FALSE;
_i_volume = 50;
+ _i_time = 0;
// set default/preferred size (320x240) pixels in HIMETRIC
HDC hDC = CreateDevDC(NULL);
_extent.cx = 320;
return S_OK;
};
-HRESULT VLCPlugin::onRun(void)
+HRESULT VLCPlugin::getVLCObject(int *i_vlc)
{
if( ! isRunning() )
{
char *psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
if( NULL != psz_mrl )
{
+ char timeBuffer[32];
+ const char *options[1];
+ int cOptions = 0;
+
+ if( _i_time )
+ {
+ snprintf(timeBuffer, sizeof(timeBuffer), ":start-time=%d", _i_time);
+ options[cOptions++] = timeBuffer;
+ }
// add default target to playlist
- VLC_AddTarget(_i_vlc, psz_mrl, NULL, 0, PLAYLIST_APPEND, PLAYLIST_END);
+ VLC_AddTarget(_i_vlc, psz_mrl, options, cOptions, PLAYLIST_APPEND, PLAYLIST_END);
CoTaskMemFree(psz_mrl);
}
}
+ *i_vlc = _i_vlc;
return S_OK;
};
if( _b_usermode )
{
- /* run vlc if not done already */
- HRESULT result = onRun();
+ /* will run vlc if not done already */
+ int i_vlc;
+ HRESULT result = getVLCObject(&i_vlc);
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);
+ VLC_VariableSet(i_vlc, "conf::width", val);
val.i_int = posRect.bottom-posRect.top;
- VLC_VariableSet(_i_vlc, "conf::height", val);
+ 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);
+ VLC_VariableSet(i_vlc, "drawable", val);
- if( _b_autoplay & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
+ if( _b_autoplay & (VLC_PlaylistNumberOfItems(i_vlc) > 0) )
{
- VLC_Play(_i_vlc);
+ VLC_Play(i_vlc);
fireOnPlayEvent();
}
}
}
};
+void VLCPlugin::setTime(int seconds)
+{
+ if( seconds < 0 )
+ seconds = 0;
+
+ if( seconds != _i_time )
+ {
+ _i_time = seconds;
+ if( isRunning() )
+ {
+ VLC_TimeSet(_i_vlc, seconds, VLC_FALSE);
+ }
+ setDirty(TRUE);
+ }
+};
+
void VLCPlugin::setFocus(BOOL fFocus)
{
if( fFocus )
{
_p_typeinfo->AddRef();
*ppTInfo = _p_typeinfo;
- return NO_ERROR;
+ return NOERROR;
}
*ppTInfo = NULL;
return E_NOTIMPL;
STDMETHODIMP VLCControl::play(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_Play(i_vlc);
_p_instance->fireOnPlayEvent();
- return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::pause(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_Pause(i_vlc);
_p_instance->fireOnPauseEvent();
- return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::stop(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_Stop(i_vlc);
_p_instance->fireOnStopEvent();
- return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
if( NULL == isPlaying )
return E_POINTER;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = NOERROR;
+ if( _p_instance->isRunning() )
{
- *isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE;
- return NOERROR;
+ int i_vlc;
+ result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ *isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE;
+ return NOERROR;
+ }
}
*isPlaying = VARIANT_FALSE;
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_Position(float *position)
if( NULL == position )
return E_POINTER;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = E_UNEXPECTED;
+ if( _p_instance->isRunning() )
{
- *position = VLC_PositionGet(i_vlc);
- return NOERROR;
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ *position = VLC_PositionGet(i_vlc);
+ return NOERROR;
+ }
}
*position = 0.0f;
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::put_Position(float position)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = E_UNEXPECTED;
+ if( _p_instance->isRunning() )
{
- VLC_PositionSet(i_vlc, position);
- return NOERROR;
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ VLC_PositionSet(i_vlc, position);
+ }
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_Time(int *seconds)
if( NULL == seconds )
return E_POINTER;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = NOERROR;
+ if( _p_instance->isRunning() )
{
- *seconds = VLC_TimeGet(i_vlc);
- return NOERROR;
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ *seconds = VLC_TimeGet(i_vlc);
+ }
}
- *seconds = 0;
- return E_UNEXPECTED;
+ else
+ *seconds = _p_instance->getTime();
+
+ return result;
};
-
+
STDMETHODIMP VLCControl::put_Time(int seconds)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
- {
- VLC_TimeSet(i_vlc, seconds, VLC_FALSE);
- return NOERROR;
- }
- return E_UNEXPECTED;
+ _p_instance->setTime(seconds);
+
+ return NOERROR;
};
STDMETHODIMP VLCControl::shuttle(int seconds)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = E_UNEXPECTED;
+ if( _p_instance->isRunning() )
{
- VLC_TimeSet(i_vlc, seconds, VLC_TRUE);
- return NOERROR;
+ int i_vlc;
+ result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ VLC_TimeSet(i_vlc, seconds, VLC_TRUE);
+ }
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::fullscreen(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = E_UNEXPECTED;
+ if( _p_instance->isRunning() )
{
- VLC_FullScreen(i_vlc);
- return NOERROR;
+ int i_vlc;
+ result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ VLC_FullScreen(i_vlc);
+ }
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_Length(int *seconds)
if( NULL == seconds )
return E_POINTER;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = NOERROR;
+ if( _p_instance->isRunning() )
{
- *seconds = VLC_LengthGet(i_vlc);
- return NOERROR;
+ int i_vlc;
+ result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ *seconds = VLC_LengthGet(i_vlc);
+ return NOERROR;
+ }
}
*seconds = 0;
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::playFaster(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = E_UNEXPECTED;
+ if( _p_instance->isRunning() )
{
- VLC_SpeedFaster(i_vlc);
- return NOERROR;
+ int i_vlc;
+ result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ VLC_SpeedFaster(i_vlc);
+ }
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::playSlower(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ HRESULT result = E_UNEXPECTED;
+ if( _p_instance->isRunning() )
{
- VLC_SpeedSlower(i_vlc);
- return NOERROR;
+ int i_vlc;
+ result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
+ {
+ VLC_SpeedSlower(i_vlc);
+ }
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_Volume(int *volume)
STDMETHODIMP VLCControl::toggleMute(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_VolumeMute(i_vlc);
- return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
if( 0 == SysStringLen(name) )
return E_INVALIDARG;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT hr = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(hr) )
{
int codePage = _p_instance->getCodePage();
char *psz_varname = CStrFromBSTR(codePage, name);
if( NULL == psz_varname )
return E_OUTOFMEMORY;
- HRESULT hr = E_INVALIDARG;
int i_type;
vlc_value_t val;
}
}
else {
- // no defined type, defaults to VARIANT type
+ // no defined type, use type in VARIANT
hr = NO_ERROR;
switch( V_VT(&value) )
{
CoTaskMemFree(val.psz_string);
}
CoTaskMemFree(psz_varname);
-
- return hr;
}
- return E_UNEXPECTED;
+ return hr;
};
STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
if( 0 == SysStringLen(name) )
return E_INVALIDARG;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT hr = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(hr) )
{
UINT codePage = _p_instance->getCodePage();
char *psz_varname = CStrFromBSTR(codePage, name);
if( NULL == psz_varname )
return E_OUTOFMEMORY;
- HRESULT hr = E_INVALIDARG;
+ hr = E_INVALIDARG;
vlc_value_t val;
int i_type;
CoTaskMemFree(psz_varname);
return hr;
}
- return E_UNEXPECTED;
+ return hr;
};
static void freeTargetOptions(char **cOptions, int cOptionCount)
if( 0 == SysStringLen(uri) )
return E_INVALIDARG;
- HRESULT hr = E_UNEXPECTED;
-
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT hr = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(hr) )
{
char *cUri = CStrFromBSTR(CP_UTF8, uri);
if( NULL == cUri )
if( NULL == index )
return E_POINTER;
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
*index = VLC_PlaylistIndex(i_vlc);
return NOERROR;
}
*index = 0;
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
*count = VLC_PlaylistNumberOfItems(i_vlc);
return NOERROR;
}
*count = 0;
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::playlistNext(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_PlaylistNext(i_vlc);
return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::playlistPrev(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_PlaylistPrev(i_vlc);
return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::playlistClear(void)
{
- int i_vlc = _p_instance->getVLCObject();
- if( i_vlc )
+ int i_vlc;
+ HRESULT result = _p_instance->getVLCObject(&i_vlc);
+ if( SUCCEEDED(result) )
{
VLC_PlaylistClear(i_vlc);
return NOERROR;
}
- return E_UNEXPECTED;
+ return result;
};
STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)