2005-03-02 17:47:31 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* vlccontrol.cpp: ActiveX control for VLC
|
|
|
|
*****************************************************************************
|
2005-07-09 08:17:09 +02:00
|
|
|
* Copyright (C) 2005 the VideoLAN team
|
2005-03-02 17:47:31 +01:00
|
|
|
*
|
|
|
|
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-01-13 00:10:04 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2005-03-02 17:47:31 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "vlccontrol.h"
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
using namespace std;
|
|
|
|
|
2005-03-02 17:47:31 +01:00
|
|
|
VLCControl::~VLCControl()
|
|
|
|
{
|
|
|
|
if( _p_typeinfo )
|
|
|
|
_p_typeinfo->Release();
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT VLCControl::getTypeInfo(void)
|
|
|
|
{
|
|
|
|
HRESULT hr = NOERROR;
|
|
|
|
if( NULL == _p_typeinfo )
|
|
|
|
{
|
|
|
|
ITypeLib *p_typelib;
|
|
|
|
|
|
|
|
HRESULT hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
|
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl, &_p_typeinfo);
|
|
|
|
if( FAILED(hr) )
|
|
|
|
{
|
|
|
|
_p_typeinfo = NULL;
|
|
|
|
}
|
|
|
|
p_typelib->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo)
|
|
|
|
{
|
2005-04-18 13:35:18 +02:00
|
|
|
if( NULL == pctInfo )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-03-02 17:47:31 +01:00
|
|
|
if( SUCCEEDED(getTypeInfo()) )
|
|
|
|
*pctInfo = 1;
|
|
|
|
else
|
|
|
|
*pctInfo = 0;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
|
|
|
|
{
|
|
|
|
if( NULL == ppTInfo )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if( SUCCEEDED(getTypeInfo()) )
|
|
|
|
{
|
|
|
|
_p_typeinfo->AddRef();
|
|
|
|
*ppTInfo = _p_typeinfo;
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
*ppTInfo = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
|
|
|
|
UINT cNames, LCID lcid, DISPID* rgDispID)
|
|
|
|
{
|
|
|
|
if( SUCCEEDED(getTypeInfo()) )
|
|
|
|
{
|
|
|
|
return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
|
|
|
|
}
|
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid,
|
|
|
|
LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if( SUCCEEDED(getTypeInfo()) )
|
|
|
|
{
|
|
|
|
return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
}
|
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible)
|
|
|
|
{
|
|
|
|
if( NULL == isVisible )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
*isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
|
|
|
|
{
|
|
|
|
_p_instance->setVisible(isVisible != VARIANT_FALSE);
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::play(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_Play(i_vlc);
|
|
|
|
_p_instance->fireOnPlayEvent();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::pause(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_Pause(i_vlc);
|
|
|
|
_p_instance->fireOnPauseEvent();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::stop(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_Stop(i_vlc);
|
|
|
|
_p_instance->fireOnStopEvent();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
2005-08-21 19:40:32 +02:00
|
|
|
};
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
|
|
|
|
{
|
|
|
|
if( NULL == isPlaying )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
*isPlaying = VARIANT_FALSE;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_Position(float *position)
|
|
|
|
{
|
|
|
|
if( NULL == position )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*position = VLC_PositionGet(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
*position = 0.0f;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::put_Position(float position)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_PositionSet(i_vlc, position);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_Time(int *seconds)
|
|
|
|
{
|
|
|
|
if( NULL == seconds )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*seconds = VLC_TimeGet(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
*seconds = 0;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::shuttle(int seconds)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_TimeSet(i_vlc, seconds, VLC_TRUE);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::fullscreen(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_FullScreen(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_Length(int *seconds)
|
|
|
|
{
|
|
|
|
if( NULL == seconds )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*seconds = VLC_LengthGet(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
*seconds = 0;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::playFaster(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_SpeedFaster(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::playSlower(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_SpeedSlower(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_Volume(int *volume)
|
|
|
|
{
|
|
|
|
if( NULL == volume )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*volume = VLC_VolumeGet(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
*volume = 0;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::put_Volume(int volume)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_VolumeSet(i_vlc, volume);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::toggleMute(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_VolumeMute(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
2005-08-21 19:40:32 +02:00
|
|
|
STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
{
|
|
|
|
if( 0 == SysStringLen(name) )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
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;
|
2005-05-31 15:24:34 +02:00
|
|
|
vlc_value_t val;
|
|
|
|
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
if( VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type) )
|
|
|
|
{
|
|
|
|
VARIANT arg;
|
|
|
|
VariantInit(&arg);
|
|
|
|
|
|
|
|
switch( i_type )
|
|
|
|
{
|
|
|
|
case VLC_VAR_BOOL:
|
2005-10-11 18:44:53 +02:00
|
|
|
hr = VariantChangeType(&arg, &value, 0, VT_BOOL);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
val.b_bool = (VARIANT_TRUE == V_BOOL(&arg)) ? VLC_TRUE : VLC_FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VLC_VAR_INTEGER:
|
2005-05-31 15:24:34 +02:00
|
|
|
case VLC_VAR_HOTKEY:
|
2005-10-11 18:44:53 +02:00
|
|
|
hr = VariantChangeType(&arg, &value, 0, VT_I4);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
val.i_int = V_I4(&arg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VLC_VAR_FLOAT:
|
2005-10-11 18:44:53 +02:00
|
|
|
hr = VariantChangeType(&arg, &value, 0, VT_R4);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
val.f_float = V_R4(&arg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VLC_VAR_STRING:
|
2005-05-31 15:24:34 +02:00
|
|
|
case VLC_VAR_MODULE:
|
|
|
|
case VLC_VAR_FILE:
|
|
|
|
case VLC_VAR_DIRECTORY:
|
|
|
|
case VLC_VAR_VARIABLE:
|
2005-10-11 18:44:53 +02:00
|
|
|
hr = VariantChangeType(&arg, &value, 0, VT_BSTR);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
if( SUCCEEDED(hr) )
|
2005-05-31 15:24:34 +02:00
|
|
|
{
|
2006-01-23 13:00:00 +01:00
|
|
|
i_type = VLC_VAR_STRING;
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
val.psz_string = CStrFromBSTR(codePage, V_BSTR(&arg));
|
2005-05-31 15:24:34 +02:00
|
|
|
VariantClear(&arg);
|
|
|
|
}
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
break;
|
|
|
|
|
2005-05-31 15:24:34 +02:00
|
|
|
case VLC_VAR_TIME:
|
|
|
|
// use a double value to represent time (base is expressed in seconds)
|
2005-10-11 18:44:53 +02:00
|
|
|
hr = VariantChangeType(&arg, &value, 0, VT_R8);
|
2005-05-31 15:24:34 +02:00
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
val.i_time = (signed __int64)(V_R8(&arg)*1000000.0);
|
|
|
|
break;
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
|
2005-05-31 15:24:34 +02:00
|
|
|
default:
|
|
|
|
hr = DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// no defined type, defaults to VARIANT type
|
|
|
|
hr = NO_ERROR;
|
|
|
|
switch( V_VT(&value) )
|
|
|
|
{
|
|
|
|
case VT_BOOL:
|
|
|
|
val.b_bool = (VARIANT_TRUE == V_BOOL(&value)) ? VLC_TRUE : VLC_FALSE;
|
|
|
|
i_type = VLC_VAR_BOOL;
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
|
|
|
val.i_int = V_I4(&value);
|
|
|
|
i_type = VLC_VAR_INTEGER;
|
|
|
|
break;
|
|
|
|
case VT_R4:
|
|
|
|
val.f_float = V_R4(&value);
|
|
|
|
i_type = VLC_VAR_FLOAT;
|
|
|
|
break;
|
|
|
|
case VT_BSTR:
|
|
|
|
val.psz_string = CStrFromBSTR(codePage, V_BSTR(&value));
|
|
|
|
i_type = VLC_VAR_STRING;
|
|
|
|
break;
|
|
|
|
case VT_R8:
|
|
|
|
// use a double value to represent time (base is expressed in seconds)
|
|
|
|
val.i_time = (signed __int64)(V_R8(&value)*1000000.0);
|
|
|
|
i_type = VLC_VAR_TIME;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hr = DISP_E_TYPEMISMATCH;
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
}
|
|
|
|
}
|
2005-05-31 15:24:34 +02:00
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
hr = (VLC_SUCCESS == VLC_VariableSet(i_vlc, psz_varname, val)) ? NOERROR : E_FAIL;
|
|
|
|
|
|
|
|
if( (VLC_VAR_STRING == i_type) && (NULL != val.psz_string) )
|
2005-07-19 19:41:16 +02:00
|
|
|
CoTaskMemFree(val.psz_string);
|
2005-05-31 15:24:34 +02:00
|
|
|
}
|
2005-07-19 19:41:16 +02:00
|
|
|
CoTaskMemFree(psz_varname);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
|
|
|
|
{
|
|
|
|
if( NULL == value )
|
|
|
|
return E_POINTER;
|
|
|
|
|
2005-10-11 17:14:08 +02:00
|
|
|
VariantInit(value);
|
|
|
|
|
|
|
|
if( 0 == SysStringLen(name) )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
2005-10-11 17:14:08 +02:00
|
|
|
UINT codePage = _p_instance->getCodePage();
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
char *psz_varname = CStrFromBSTR(codePage, name);
|
|
|
|
if( NULL == psz_varname )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
vlc_value_t val;
|
|
|
|
int i_type;
|
|
|
|
|
|
|
|
if( (VLC_SUCCESS == VLC_VariableGet(i_vlc, psz_varname, &val))
|
|
|
|
&& (VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type)) )
|
|
|
|
{
|
|
|
|
hr = NOERROR;
|
|
|
|
switch( i_type )
|
|
|
|
{
|
|
|
|
case VLC_VAR_BOOL:
|
|
|
|
V_VT(value) = VT_BOOL;
|
|
|
|
V_BOOL(value) = val.b_bool ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VLC_VAR_INTEGER:
|
2005-05-31 15:24:34 +02:00
|
|
|
case VLC_VAR_HOTKEY:
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
V_VT(value) = VT_I4;
|
|
|
|
V_I4(value) = val.i_int;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VLC_VAR_FLOAT:
|
|
|
|
V_VT(value) = VT_R4;
|
|
|
|
V_R4(value) = val.f_float;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VLC_VAR_STRING:
|
2005-05-31 15:24:34 +02:00
|
|
|
case VLC_VAR_MODULE:
|
|
|
|
case VLC_VAR_FILE:
|
|
|
|
case VLC_VAR_DIRECTORY:
|
|
|
|
case VLC_VAR_VARIABLE:
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
V_VT(value) = VT_BSTR;
|
|
|
|
V_BSTR(value) = BSTRFromCStr(codePage, val.psz_string);
|
2005-10-11 17:14:08 +02:00
|
|
|
if( NULL != val.psz_string)
|
|
|
|
free(val.psz_string);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
break;
|
2005-05-31 15:24:34 +02:00
|
|
|
|
|
|
|
case VLC_VAR_TIME:
|
|
|
|
// use a double value to represent time (base is expressed in seconds)
|
|
|
|
V_VT(value) = VT_R8;
|
|
|
|
V_R8(value) = ((double)val.i_time)/1000000.0;
|
|
|
|
break;
|
|
|
|
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
default:
|
|
|
|
hr = DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
|
|
|
}
|
2005-07-19 19:41:16 +02:00
|
|
|
CoTaskMemFree(psz_varname);
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
2005-03-02 17:47:31 +01:00
|
|
|
static void freeTargetOptions(char **cOptions, int cOptionCount)
|
|
|
|
{
|
|
|
|
// clean up
|
2005-07-19 19:41:16 +02:00
|
|
|
if( NULL != cOptions )
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
2005-07-19 19:41:16 +02:00
|
|
|
for( int pos=0; pos<cOptionCount; ++pos )
|
|
|
|
{
|
|
|
|
char *cOption = cOptions[pos];
|
|
|
|
if( NULL != cOption )
|
|
|
|
CoTaskMemFree(cOption);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
CoTaskMemFree(cOptions);
|
2005-03-02 17:47:31 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT createTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount)
|
|
|
|
{
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
if( VT_ERROR == V_VT(options) )
|
|
|
|
{
|
|
|
|
if( DISP_E_PARAMNOTFOUND == V_ERROR(options) )
|
|
|
|
{
|
|
|
|
// optional parameter not set
|
|
|
|
*cOptions = NULL;
|
|
|
|
*cOptionCount = 0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( (VT_EMPTY == V_VT(options)) || (VT_NULL == V_VT(options)) )
|
|
|
|
{
|
|
|
|
// null parameter
|
|
|
|
*cOptions = NULL;
|
|
|
|
*cOptionCount = 0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
else if( VT_DISPATCH == V_VT(options) )
|
|
|
|
{
|
|
|
|
// collection parameter
|
|
|
|
VARIANT colEnum;
|
|
|
|
V_VT(&colEnum) = VT_UNKNOWN;
|
|
|
|
hr = GetObjectProperty(V_DISPATCH(options), DISPID_NEWENUM, colEnum);
|
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
IEnumVARIANT *enumVar;
|
|
|
|
hr = V_UNKNOWN(&colEnum)->QueryInterface(IID_IEnumVARIANT, (LPVOID *)&enumVar);
|
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
long pos = 0;
|
|
|
|
long capacity = 16;
|
|
|
|
VARIANT option;
|
|
|
|
|
2005-07-19 19:41:16 +02:00
|
|
|
*cOptions = (char **)CoTaskMemAlloc(capacity*sizeof(char *));
|
2005-03-02 17:47:31 +01:00
|
|
|
if( NULL != *cOptions )
|
|
|
|
{
|
|
|
|
ZeroMemory(*cOptions, sizeof(char *)*capacity);
|
|
|
|
while( SUCCEEDED(hr) && (S_OK == enumVar->Next(1, &option, NULL)) )
|
|
|
|
{
|
|
|
|
if( VT_BSTR == V_VT(&option) )
|
|
|
|
{
|
|
|
|
char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));
|
|
|
|
(*cOptions)[pos] = cOption;
|
|
|
|
if( NULL != cOption )
|
|
|
|
{
|
|
|
|
++pos;
|
|
|
|
if( pos == capacity )
|
|
|
|
{
|
2005-07-19 19:41:16 +02:00
|
|
|
char **moreOptions = (char **)CoTaskMemRealloc(*cOptions, (capacity+16)*sizeof(char *));
|
2005-03-02 17:47:31 +01:00
|
|
|
if( NULL != moreOptions )
|
|
|
|
{
|
|
|
|
ZeroMemory(moreOptions+capacity, sizeof(char *)*16);
|
|
|
|
capacity += 16;
|
|
|
|
*cOptions = moreOptions;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2005-07-19 19:41:16 +02:00
|
|
|
hr = ( SysStringLen(V_BSTR(&option)) > 0 ) ?
|
|
|
|
E_OUTOFMEMORY : E_INVALIDARG;
|
2005-03-02 17:47:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
VariantClear(&option);
|
|
|
|
}
|
|
|
|
*cOptionCount = pos;
|
|
|
|
if( FAILED(hr) )
|
|
|
|
{
|
|
|
|
// free already processed elements
|
|
|
|
freeTargetOptions(*cOptions, *cOptionCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
2005-07-19 19:41:16 +02:00
|
|
|
|
2005-03-02 17:47:31 +01:00
|
|
|
enumVar->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( V_ISARRAY(options) )
|
|
|
|
{
|
|
|
|
// array parameter
|
|
|
|
SAFEARRAY *array = V_ISBYREF(options) ? *V_ARRAYREF(options) : V_ARRAY(options);
|
|
|
|
|
|
|
|
if( SafeArrayGetDim(array) != 1 )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
long lBound = 0;
|
|
|
|
long uBound = 0;
|
|
|
|
SafeArrayGetLBound(array, 1, &lBound);
|
|
|
|
SafeArrayGetUBound(array, 1, &uBound);
|
|
|
|
|
|
|
|
// have we got any options
|
2005-10-17 16:37:20 +02:00
|
|
|
if( uBound >= lBound )
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
|
|
|
VARTYPE vType;
|
2005-07-19 19:41:16 +02:00
|
|
|
hr = SafeArrayGetVartype(array, &vType);
|
2005-03-02 17:47:31 +01:00
|
|
|
if( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
long pos;
|
|
|
|
|
|
|
|
// marshall options into an array of C strings
|
|
|
|
if( VT_VARIANT == vType )
|
|
|
|
{
|
2006-02-21 17:38:23 +01:00
|
|
|
*cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
|
2005-07-19 19:41:16 +02:00
|
|
|
if( NULL == *cOptions )
|
2005-03-02 17:47:31 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2006-02-21 17:38:23 +01:00
|
|
|
ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
|
|
|
|
for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
|
|
|
VARIANT option;
|
|
|
|
hr = SafeArrayGetElement(array, &pos, &option);
|
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
if( VT_BSTR == V_VT(&option) )
|
|
|
|
{
|
|
|
|
char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));
|
|
|
|
(*cOptions)[pos-lBound] = cOption;
|
|
|
|
if( NULL == cOption )
|
2005-07-19 19:41:16 +02:00
|
|
|
hr = ( SysStringLen(V_BSTR(&option)) > 0 ) ?
|
|
|
|
E_OUTOFMEMORY : E_INVALIDARG;
|
2005-03-02 17:47:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
VariantClear(&option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( VT_BSTR == vType )
|
|
|
|
{
|
2006-02-21 17:38:23 +01:00
|
|
|
*cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
|
2005-07-19 19:41:16 +02:00
|
|
|
if( NULL == *cOptions )
|
2005-03-02 17:47:31 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2006-02-21 17:38:23 +01:00
|
|
|
ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
|
|
|
|
for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
|
|
|
BSTR option;
|
|
|
|
hr = SafeArrayGetElement(array, &pos, &option);
|
|
|
|
if( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
char *cOption = CStrFromBSTR(codePage, option);
|
2005-07-19 19:41:16 +02:00
|
|
|
|
2005-03-02 17:47:31 +01:00
|
|
|
(*cOptions)[pos-lBound] = cOption;
|
|
|
|
if( NULL == cOption )
|
2005-07-19 19:41:16 +02:00
|
|
|
hr = ( SysStringLen(option) > 0 ) ?
|
|
|
|
E_OUTOFMEMORY : E_INVALIDARG;
|
2005-03-02 17:47:31 +01:00
|
|
|
SysFreeString(option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-07-19 19:41:16 +02:00
|
|
|
else
|
|
|
|
{
|
2005-03-02 17:47:31 +01:00
|
|
|
// unsupported type
|
|
|
|
return E_INVALIDARG;
|
2005-07-19 19:41:16 +02:00
|
|
|
}
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
*cOptionCount = pos-lBound;
|
|
|
|
if( FAILED(hr) )
|
|
|
|
{
|
|
|
|
// free already processed elements
|
|
|
|
freeTargetOptions(*cOptions, *cOptionCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// empty array
|
|
|
|
*cOptions = NULL;
|
|
|
|
*cOptionCount = 0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
** use VARIANT rather than a SAFEARRAY as argument type
|
|
|
|
** for compatibility with some scripting language (JScript)
|
|
|
|
*/
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position)
|
|
|
|
{
|
2005-04-18 13:35:18 +02:00
|
|
|
if( 0 == SysStringLen(uri) )
|
2005-03-02 17:47:31 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
HRESULT hr = E_UNEXPECTED;
|
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
2005-08-21 19:40:32 +02:00
|
|
|
char *cUri = CStrFromBSTR(CP_UTF8, uri);
|
2005-03-02 17:47:31 +01:00
|
|
|
if( NULL == cUri )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
int cOptionsCount;
|
|
|
|
char **cOptions;
|
|
|
|
|
2005-08-21 19:40:32 +02:00
|
|
|
if( FAILED(createTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
|
2005-03-02 17:47:31 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
if( VLC_SUCCESS <= VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position) )
|
|
|
|
{
|
|
|
|
hr = NOERROR;
|
2005-08-21 19:40:32 +02:00
|
|
|
if( mode & PLAYLIST_GO )
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
_p_instance->fireOnPlayEvent();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
2005-08-21 19:40:32 +02:00
|
|
|
if( mode & PLAYLIST_GO )
|
src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h
vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.
main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
2005-05-11 18:56:46 +02:00
|
|
|
_p_instance->fireOnStopEvent();
|
|
|
|
}
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
freeTargetOptions(cOptions, cOptionsCount);
|
2005-07-19 19:41:16 +02:00
|
|
|
CoTaskMemFree(cUri);
|
2005-03-02 17:47:31 +01:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
|
|
|
|
{
|
|
|
|
if( NULL == index )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*index = VLC_PlaylistIndex(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
*index = 0;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
*count = VLC_PlaylistNumberOfItems(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
2005-07-19 19:41:16 +02:00
|
|
|
*count = 0;
|
2005-03-02 17:47:31 +01:00
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::playlistNext(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_PlaylistNext(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::playlistPrev(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_PlaylistPrev(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::playlistClear(void)
|
|
|
|
{
|
|
|
|
int i_vlc = _p_instance->getVLCObject();
|
|
|
|
if( i_vlc )
|
|
|
|
{
|
|
|
|
VLC_PlaylistClear(i_vlc);
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
|
|
|
|
{
|
|
|
|
if( NULL == version )
|
2005-04-18 13:35:18 +02:00
|
|
|
return E_POINTER;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
|
|
|
const char *versionStr = VLC_Version();
|
|
|
|
if( NULL != versionStr )
|
|
|
|
{
|
|
|
|
*version = BSTRFromCStr(_p_instance->getCodePage(), versionStr);
|
|
|
|
|
|
|
|
return NULL == *version ? E_OUTOFMEMORY : NOERROR;
|
|
|
|
}
|
|
|
|
*version = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
};
|
|
|
|
|
2005-08-21 19:40:32 +02:00
|
|
|
STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
|
|
|
|
{
|
|
|
|
if( NULL == mrl )
|
|
|
|
return E_POINTER;
|
|
|
|
|
2005-09-16 18:10:42 +02:00
|
|
|
*mrl = SysAllocStringLen(_p_instance->getMRL(),
|
|
|
|
SysStringLen(_p_instance->getMRL()));
|
2005-08-21 19:40:32 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|