1 /*****************************************************************************
2 * vlccontrol.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
24 #include "vlccontrol.h"
30 VLCControl::~VLCControl()
33 _p_typeinfo->Release();
36 HRESULT VLCControl::getTypeInfo(void)
39 if( NULL == _p_typeinfo )
43 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
46 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl, &_p_typeinfo);
57 STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo)
62 if( SUCCEEDED(getTypeInfo()) )
70 STDMETHODIMP VLCControl::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
75 if( SUCCEEDED(getTypeInfo()) )
77 _p_typeinfo->AddRef();
78 *ppTInfo = _p_typeinfo;
85 STDMETHODIMP VLCControl::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
86 UINT cNames, LCID lcid, DISPID* rgDispID)
88 if( SUCCEEDED(getTypeInfo()) )
90 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
95 STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid,
96 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
97 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
99 if( SUCCEEDED(getTypeInfo()) )
101 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
102 pVarResult, pExcepInfo, puArgErr);
107 STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible)
109 if( NULL == isVisible )
112 *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
117 STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
119 _p_instance->setVisible(isVisible != VARIANT_FALSE);
124 STDMETHODIMP VLCControl::play(void)
126 libvlc_instance_t* p_libvlc;
127 HRESULT result = _p_instance->getVLC(&p_libvlc);
128 if( SUCCEEDED(result) )
130 libvlc_exception_t ex;
131 libvlc_exception_init(&ex);
133 libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
134 if( libvlc_exception_raised(&ex) )
136 _p_instance->setErrorInfo(IID_IVLCControl,
137 libvlc_exception_get_message(&ex));
138 libvlc_exception_clear(&ex);
141 _p_instance->fireOnPlayEvent();
147 STDMETHODIMP VLCControl::pause(void)
149 libvlc_instance_t* p_libvlc;
150 HRESULT result = _p_instance->getVLC(&p_libvlc);
151 if( SUCCEEDED(result) )
153 libvlc_exception_t ex;
154 libvlc_exception_init(&ex);
156 libvlc_playlist_pause(p_libvlc, &ex);
157 if( libvlc_exception_raised(&ex) )
159 _p_instance->setErrorInfo(IID_IVLCControl,
160 libvlc_exception_get_message(&ex));
161 libvlc_exception_clear(&ex);
164 _p_instance->fireOnPauseEvent();
170 STDMETHODIMP VLCControl::stop(void)
172 libvlc_instance_t* p_libvlc;
173 HRESULT result = _p_instance->getVLC(&p_libvlc);
174 if( SUCCEEDED(result) )
176 libvlc_exception_t ex;
177 libvlc_exception_init(&ex);
179 libvlc_playlist_stop(p_libvlc, &ex);
180 if( libvlc_exception_raised(&ex) )
182 _p_instance->setErrorInfo(IID_IVLCControl,
183 libvlc_exception_get_message(&ex));
184 libvlc_exception_clear(&ex);
189 _p_instance->fireOnStopEvent();
193 STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
195 if( NULL == isPlaying )
198 HRESULT result = NOERROR;
199 if( _p_instance->isRunning() )
201 libvlc_instance_t *p_libvlc;
202 result = _p_instance->getVLC(&p_libvlc);
203 if( SUCCEEDED(result) )
205 if( libvlc_playlist_isplaying(p_libvlc, NULL) )
206 *isPlaying = VARIANT_TRUE;
208 *isPlaying = VARIANT_FALSE;
212 *isPlaying = VARIANT_FALSE;
216 STDMETHODIMP VLCControl::get_Position(float *position)
218 if( NULL == position )
222 libvlc_instance_t* p_libvlc;
223 HRESULT result = E_UNEXPECTED;
224 result = _p_instance->getVLC(&p_libvlc);
225 if( SUCCEEDED(result) )
227 libvlc_exception_t ex;
228 libvlc_exception_init(&ex);
230 libvlc_media_player_t *p_md;
231 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
232 if( !libvlc_exception_raised(&ex) )
234 *position = libvlc_media_player_get_position(p_md, &ex);
235 libvlc_media_player_release(p_md);
236 if( ! libvlc_exception_raised(&ex) )
241 _p_instance->setErrorInfo(IID_IVLCControl,
242 libvlc_exception_get_message(&ex));
243 libvlc_exception_clear(&ex);
249 STDMETHODIMP VLCControl::put_Position(float position)
251 HRESULT result = E_UNEXPECTED;
252 libvlc_instance_t* p_libvlc;
253 result = _p_instance->getVLC(&p_libvlc);
254 if( SUCCEEDED(result) )
256 libvlc_exception_t ex;
257 libvlc_exception_init(&ex);
259 libvlc_media_player_t *p_md;
260 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
261 if( ! libvlc_exception_raised(&ex) )
263 libvlc_media_player_set_position(p_md, position, &ex);
264 libvlc_media_player_release(p_md);
265 if( ! libvlc_exception_raised(&ex) )
270 _p_instance->setErrorInfo(IID_IVLCControl,
271 libvlc_exception_get_message(&ex));
272 libvlc_exception_clear(&ex);
278 STDMETHODIMP VLCControl::get_Time(int *seconds)
280 if( NULL == seconds )
284 libvlc_instance_t* p_libvlc;
285 HRESULT result = _p_instance->getVLC(&p_libvlc);
286 if( SUCCEEDED(result) )
288 libvlc_exception_t ex;
289 libvlc_exception_init(&ex);
291 libvlc_media_player_t *p_md;
292 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
293 if( ! libvlc_exception_raised(&ex) )
295 *seconds = libvlc_media_player_get_time(p_md, &ex);
296 libvlc_media_player_release(p_md);
297 if( ! libvlc_exception_raised(&ex) )
302 _p_instance->setErrorInfo(IID_IVLCControl,
303 libvlc_exception_get_message(&ex));
304 libvlc_exception_clear(&ex);
310 STDMETHODIMP VLCControl::put_Time(int seconds)
312 /* setTime function of the plugin sets the time. */
313 _p_instance->setTime(seconds);
317 STDMETHODIMP VLCControl::shuttle(int seconds)
319 libvlc_instance_t* p_libvlc;
320 HRESULT result = _p_instance->getVLC(&p_libvlc);
321 if( SUCCEEDED(result) )
323 libvlc_exception_t ex;
324 libvlc_exception_init(&ex);
326 libvlc_media_player_t *p_md;
327 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
328 if( ! libvlc_exception_raised(&ex) )
330 if( seconds < 0 ) seconds = 0;
331 libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex);
332 libvlc_media_player_release(p_md);
333 if( ! libvlc_exception_raised(&ex) )
338 _p_instance->setErrorInfo(IID_IVLCControl,
339 libvlc_exception_get_message(&ex));
340 libvlc_exception_clear(&ex);
347 STDMETHODIMP VLCControl::fullscreen(void)
349 HRESULT result = E_UNEXPECTED;
350 if( _p_instance->isRunning() )
352 libvlc_instance_t *p_libvlc;
353 result = _p_instance->getVLC(&p_libvlc);
354 if( SUCCEEDED(result) )
356 if( libvlc_playlist_isplaying(p_libvlc, NULL) )
358 libvlc_media_player_t *p_md =
359 libvlc_playlist_get_media_player(p_libvlc, NULL);
362 libvlc_toggle_fullscreen(p_md, NULL);
363 libvlc_media_player_release(p_md);
371 STDMETHODIMP VLCControl::get_Length(int *seconds)
373 if( NULL == seconds )
377 libvlc_instance_t* p_libvlc;
378 HRESULT result = _p_instance->getVLC(&p_libvlc);
379 if( SUCCEEDED(result) )
381 libvlc_exception_t ex;
382 libvlc_exception_init(&ex);
384 libvlc_media_player_t *p_md;
385 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
386 if( ! libvlc_exception_raised(&ex) )
388 *seconds = (double)libvlc_media_player_get_length(p_md, &ex);
389 libvlc_media_player_release(p_md);
390 if( ! libvlc_exception_raised(&ex) )
395 _p_instance->setErrorInfo(IID_IVLCControl,
396 libvlc_exception_get_message(&ex));
397 libvlc_exception_clear(&ex);
404 STDMETHODIMP VLCControl::playFaster(void)
406 HRESULT result = E_UNEXPECTED;
407 if( _p_instance->isRunning() )
409 libvlc_instance_t *p_libvlc;
410 result = _p_instance->getVLC(&p_libvlc);
411 if( SUCCEEDED(result) )
413 VLC_SpeedFaster(i_vlc);
419 STDMETHODIMP VLCControl::playSlower(void)
421 HRESULT result = E_UNEXPECTED;
422 if( _p_instance->isRunning() )
424 libvlc_instance_t *p_libvlc;
425 result = _p_instance->getVLC(&p_libvlc);
426 if( SUCCEEDED(result) )
428 VLC_SpeedSlower(i_vlc);
434 STDMETHODIMP VLCControl::get_Volume(int *volume)
439 *volume = _p_instance->getVolume();
443 STDMETHODIMP VLCControl::put_Volume(int volume)
445 _p_instance->setVolume(volume);
449 STDMETHODIMP VLCControl::toggleMute(void)
451 libvlc_instance_t* p_libvlc;
452 HRESULT result = _p_instance->getVLC(&p_libvlc);
453 if( SUCCEEDED(result) )
455 libvlc_exception_t ex;
456 libvlc_exception_init(&ex);
458 libvlc_audio_toggle_mute(p_libvlc, &ex);
459 if( libvlc_exception_raised(&ex) )
461 _p_instance->setErrorInfo(IID_IVLCControl,
462 libvlc_exception_get_message(&ex));
463 libvlc_exception_clear(&ex);
471 STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
473 if( 0 == SysStringLen(name) )
476 libvlc_instance_t *p_libvlc;
477 HRESULT hr = _p_instance->getVLC(&p_libvlc);
480 int codePage = _p_instance->getCodePage();
481 char *psz_varname = CStrFromBSTR(codePage, name);
482 if( NULL == psz_varname )
483 return E_OUTOFMEMORY;
488 if( VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type) )
496 hr = VariantChangeType(&arg, &value, 0, VT_BOOL);
498 val.b_bool = (VARIANT_TRUE == V_BOOL(&arg)) ? true : false;
501 case VLC_VAR_INTEGER:
503 hr = VariantChangeType(&arg, &value, 0, VT_I4);
505 val.i_int = V_I4(&arg);
509 hr = VariantChangeType(&arg, &value, 0, VT_R4);
511 val.f_float = V_R4(&arg);
517 case VLC_VAR_DIRECTORY:
518 case VLC_VAR_VARIABLE:
519 hr = VariantChangeType(&arg, &value, 0, VT_BSTR);
522 i_type = VLC_VAR_STRING;
523 val.psz_string = CStrFromBSTR(codePage, V_BSTR(&arg));
529 // use a double value to represent time (base is expressed in seconds)
530 hr = VariantChangeType(&arg, &value, 0, VT_R8);
532 val.i_time = (signed __int64)(V_R8(&arg)*1000000.0);
536 hr = DISP_E_TYPEMISMATCH;
540 // no defined type, use type in VARIANT
542 switch( V_VT(&value) )
545 val.b_bool = (VARIANT_TRUE == V_BOOL(&value)) ? true : false;
546 i_type = VLC_VAR_BOOL;
549 val.i_int = V_I4(&value);
550 i_type = VLC_VAR_INTEGER;
553 val.f_float = V_R4(&value);
554 i_type = VLC_VAR_FLOAT;
557 val.psz_string = CStrFromBSTR(codePage, V_BSTR(&value));
558 i_type = VLC_VAR_STRING;
561 // use a double value to represent time (base is expressed in seconds)
562 val.i_time = (signed __int64)(V_R8(&value)*1000000.0);
563 i_type = VLC_VAR_TIME;
566 hr = DISP_E_TYPEMISMATCH;
571 hr = (VLC_SUCCESS == VLC_VariableSet(i_vlc, psz_varname, val)) ? NOERROR : E_FAIL;
573 if( (VLC_VAR_STRING == i_type) && (NULL != val.psz_string) )
574 CoTaskMemFree(val.psz_string);
576 CoTaskMemFree(psz_varname);
581 STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
588 if( 0 == SysStringLen(name) )
591 libvlc_instance_t *p_libvlc;
592 HRESULT hr = _p_instance->getVLC(&p_libvlc);
595 UINT codePage = _p_instance->getCodePage();
596 char *psz_varname = CStrFromBSTR(codePage, name);
597 if( NULL == psz_varname )
598 return E_OUTOFMEMORY;
605 if( (VLC_SUCCESS == VLC_VariableGet(i_vlc, psz_varname, &val))
606 && (VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type)) )
612 V_VT(value) = VT_BOOL;
613 V_BOOL(value) = val.b_bool ? VARIANT_TRUE : VARIANT_FALSE;
616 case VLC_VAR_INTEGER:
619 V_I4(value) = val.i_int;
624 V_R4(value) = val.f_float;
630 case VLC_VAR_DIRECTORY:
631 case VLC_VAR_VARIABLE:
632 V_VT(value) = VT_BSTR;
633 V_BSTR(value) = BSTRFromCStr(codePage, val.psz_string);
634 if( NULL != val.psz_string)
635 free(val.psz_string);
639 // use a double value to represent time (base is expressed in seconds)
641 V_R8(value) = ((double)val.i_time)/1000000.0;
645 hr = DISP_E_TYPEMISMATCH;
648 CoTaskMemFree(psz_varname);
654 void VLCControl::FreeTargetOptions(char **cOptions, int cOptionCount)
657 if( NULL != cOptions )
659 for( int pos=0; pos<cOptionCount; ++pos )
661 char *cOption = cOptions[pos];
662 if( NULL != cOption )
663 CoTaskMemFree(cOption);
667 CoTaskMemFree(cOptions);
671 static HRESULT parseStringOptions(int codePage, BSTR bstr, char*** cOptions, int *cOptionCount)
673 HRESULT hr = E_INVALIDARG;
674 if( SysStringLen(bstr) > 0 )
677 char *s = CStrFromBSTR(codePage, bstr);
682 char **options = (char **)CoTaskMemAlloc(capacity*sizeof(char *));
687 char *end = val + strlen(val);
690 // skip leading blanks
692 && ((*val == ' ' ) || (*val == '\t')) )
696 // skip till we get a blank character
702 if( ('\'' == c) || ('"' == c) )
704 // skip till end of string
705 while( (val < end) && (*(val++) != c ) );
711 if( nOptions == capacity )
714 char **moreOptions = (char **)CoTaskMemRealloc(options, capacity*sizeof(char*));
717 /* failed to allocate more memory */
719 /* return what we got so far */
720 *cOptionCount = nOptions;
724 options = moreOptions;
727 options[nOptions] = (char *)CoTaskMemAlloc(val-start);
728 if( options[nOptions] )
730 memcpy(options[nOptions], start, val-start);
735 /* failed to allocate memory */
737 /* return what we got so far */
738 *cOptionCount = nOptions;
744 // must be end of string
747 *cOptionCount = nOptions;
757 HRESULT VLCControl::CreateTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount)
759 HRESULT hr = E_INVALIDARG;
760 if( VT_ERROR == V_VT(options) )
762 if( DISP_E_PARAMNOTFOUND == V_ERROR(options) )
764 // optional parameter not set
770 else if( (VT_EMPTY == V_VT(options)) || (VT_NULL == V_VT(options)) )
777 else if( VT_DISPATCH == V_VT(options) )
779 // if object is a collection, retrieve enumerator
781 V_VT(&colEnum) = VT_UNKNOWN;
782 hr = GetObjectProperty(V_DISPATCH(options), DISPID_NEWENUM, colEnum);
785 IEnumVARIANT *enumVar;
786 hr = V_UNKNOWN(&colEnum)->QueryInterface(IID_IEnumVARIANT, (LPVOID *)&enumVar);
793 *cOptions = (char **)CoTaskMemAlloc(capacity*sizeof(char *));
794 if( NULL != *cOptions )
796 ZeroMemory(*cOptions, sizeof(char *)*capacity);
797 while( SUCCEEDED(hr) && (S_OK == enumVar->Next(1, &option, NULL)) )
799 if( VT_BSTR == V_VT(&option) )
801 char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));
802 (*cOptions)[pos] = cOption;
803 if( NULL != cOption )
806 if( pos == capacity )
808 char **moreOptions = (char **)CoTaskMemRealloc(*cOptions, (capacity+16)*sizeof(char *));
809 if( NULL != moreOptions )
811 ZeroMemory(moreOptions+capacity, sizeof(char *)*16);
813 *cOptions = moreOptions;
820 hr = ( SysStringLen(V_BSTR(&option)) > 0 ) ?
821 E_OUTOFMEMORY : E_INVALIDARG;
826 VariantClear(&option);
831 // free already processed elements
832 FreeTargetOptions(*cOptions, *cOptionCount);
843 // coerce object into a string and parse it
845 VariantInit(&v_name);
846 hr = VariantChangeType(&v_name, options, 0, VT_BSTR);
849 hr = parseStringOptions(codePage, V_BSTR(&v_name), cOptions, cOptionCount);
850 VariantClear(&v_name);
854 else if( V_ISARRAY(options) )
857 SAFEARRAY *array = V_ISBYREF(options) ? *V_ARRAYREF(options) : V_ARRAY(options);
859 if( SafeArrayGetDim(array) != 1 )
864 SafeArrayGetLBound(array, 1, &lBound);
865 SafeArrayGetUBound(array, 1, &uBound);
867 // have we got any options
868 if( uBound >= lBound )
871 hr = SafeArrayGetVartype(array, &vType);
877 // marshall options into an array of C strings
878 if( VT_VARIANT == vType )
880 *cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
881 if( NULL == *cOptions )
882 return E_OUTOFMEMORY;
884 ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
885 for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
888 hr = SafeArrayGetElement(array, &pos, &option);
891 if( VT_BSTR == V_VT(&option) )
893 char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));
894 (*cOptions)[pos-lBound] = cOption;
895 if( NULL == cOption )
896 hr = ( SysStringLen(V_BSTR(&option)) > 0 ) ?
897 E_OUTOFMEMORY : E_INVALIDARG;
901 VariantClear(&option);
905 else if( VT_BSTR == vType )
907 *cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
908 if( NULL == *cOptions )
909 return E_OUTOFMEMORY;
911 ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
912 for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
915 hr = SafeArrayGetElement(array, &pos, &option);
918 char *cOption = CStrFromBSTR(codePage, option);
920 (*cOptions)[pos-lBound] = cOption;
921 if( NULL == cOption )
922 hr = ( SysStringLen(option) > 0 ) ?
923 E_OUTOFMEMORY : E_INVALIDARG;
924 SysFreeString(option);
934 *cOptionCount = pos-lBound;
937 // free already processed elements
938 FreeTargetOptions(*cOptions, *cOptionCount);
949 else if( VT_UNKNOWN == V_VT(options) )
951 // coerce object into a string and parse it
953 VariantInit(&v_name);
954 hr = VariantChangeType(&v_name, options, 0, VT_BSTR);
957 hr = parseStringOptions(codePage, V_BSTR(&v_name), cOptions, cOptionCount);
958 VariantClear(&v_name);
961 else if( VT_BSTR == V_VT(options) )
963 hr = parseStringOptions(codePage, V_BSTR(options), cOptions, cOptionCount);
969 ** use VARIANT rather than a SAFEARRAY as argument type
970 ** for compatibility with some scripting language (JScript)
973 STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position)
975 if( 0 == SysStringLen(uri) )
978 libvlc_instance_t *p_libvlc;
979 HRESULT hr = _p_instance->getVLC(&p_libvlc);
982 char *cUri = CStrFromBSTR(CP_UTF8, uri);
984 return E_OUTOFMEMORY;
989 if( FAILED(CreateTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
992 if( VLC_SUCCESS <= VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position) )
995 if( mode & PLAYLIST_GO )
996 _p_instance->fireOnPlayEvent();
1001 if( mode & PLAYLIST_GO )
1002 _p_instance->fireOnStopEvent();
1005 FreeTargetOptions(cOptions, cOptionsCount);
1006 CoTaskMemFree(cUri);
1011 STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
1016 libvlc_instance_t *p_libvlc;
1017 HRESULT result = _p_instance->getVLC(&p_libvlc);
1018 if( SUCCEEDED(result) )
1020 *index = VLC_PlaylistIndex(i_vlc);
1027 STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
1033 libvlc_instance_t* p_libvlc;
1034 HRESULT result = _p_instance->getVLC(&p_libvlc);
1035 if( SUCCEEDED(result) )
1037 libvlc_exception_t ex;
1038 libvlc_exception_init(&ex);
1040 *count = libvlc_playlist_items_count(p_libvlc, &ex);
1041 if( libvlc_exception_raised(&ex) )
1043 _p_instance->setErrorInfo(IID_IVLCControl,
1044 libvlc_exception_get_message(&ex));
1045 libvlc_exception_clear(&ex);
1053 STDMETHODIMP VLCControl::playlistNext(void)
1055 libvlc_instance_t* p_libvlc;
1056 HRESULT result = _p_instance->getVLC(&p_libvlc);
1057 if( SUCCEEDED(result) )
1059 libvlc_exception_t ex;
1060 libvlc_exception_init(&ex);
1062 libvlc_playlist_next(p_libvlc, &ex);
1063 if( libvlc_exception_raised(&ex) )
1065 _p_instance->setErrorInfo(IID_IVLCControl,
1066 libvlc_exception_get_message(&ex));
1067 libvlc_exception_clear(&ex);
1075 STDMETHODIMP VLCControl::playlistPrev(void)
1077 libvlc_instance_t* p_libvlc;
1078 HRESULT result = _p_instance->getVLC(&p_libvlc);
1079 if( SUCCEEDED(result) )
1081 libvlc_exception_t ex;
1082 libvlc_exception_init(&ex);
1084 libvlc_playlist_prev(p_libvlc, &ex);
1085 if( libvlc_exception_raised(&ex) )
1087 _p_instance->setErrorInfo(IID_IVLCControl,
1088 libvlc_exception_get_message(&ex));
1089 libvlc_exception_clear(&ex);
1097 STDMETHODIMP VLCControl::playlistClear(void)
1099 libvlc_instance_t* p_libvlc;
1100 HRESULT result = _p_instance->getVLC(&p_libvlc);
1101 if( SUCCEEDED(result) )
1103 libvlc_exception_t ex;
1104 libvlc_exception_init(&ex);
1106 libvlc_playlist_clear(p_libvlc, &ex);
1107 if( libvlc_exception_raised(&ex) )
1109 _p_instance->setErrorInfo(IID_IVLCControl,
1110 libvlc_exception_get_message(&ex));
1111 libvlc_exception_clear(&ex);
1119 STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
1121 if( NULL == version )
1124 const char *versionStr = libvlc_get_version();
1125 if( NULL != versionStr )
1127 *version = BSTRFromCStr(CP_UTF8, versionStr);
1128 return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
1134 STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
1139 *mrl = SysAllocStringLen(_p_instance->getMRL(),
1140 SysStringLen(_p_instance->getMRL()));
1144 STDMETHODIMP VLCControl::put_MRL(BSTR mrl)
1146 _p_instance->setMRL(mrl);
1151 STDMETHODIMP VLCControl::get_AutoPlay(VARIANT_BOOL *autoplay)
1153 if( NULL == autoplay )
1156 *autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
1160 STDMETHODIMP VLCControl::put_AutoPlay(VARIANT_BOOL autoplay)
1162 _p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
1166 STDMETHODIMP VLCControl::get_AutoLoop(VARIANT_BOOL *autoloop)
1168 if( NULL == autoloop )
1171 *autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
1175 STDMETHODIMP VLCControl::put_AutoLoop(VARIANT_BOOL autoloop)
1177 _p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);