vlccontrol.cpp 20.3 KB
Newer Older
1 2 3
/*****************************************************************************
 * vlccontrol.cpp: ActiveX control for VLC
 *****************************************************************************
4
 * Copyright (C) 2005-2010 the VideoLAN team
5 6
 *
 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7
 *          Jean-Paul Saman <jpsaman@videolan.org>
8 9 10 11 12 13 14 15 16 17 18
 *
 * 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.
 *
19 20 21
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23 24 25 26 27 28
 *****************************************************************************/

#include "plugin.h"
#include "vlccontrol.h"

#include "utils.h"

29 30
using namespace std;

31 32 33 34 35 36 37 38 39 40 41 42 43
VLCControl::~VLCControl()
{
    if( _p_typeinfo )
        _p_typeinfo->Release();
};

HRESULT VLCControl::getTypeInfo(void)
{
    HRESULT hr = NOERROR;
    if( NULL == _p_typeinfo )
    {
        ITypeLib *p_typelib;

44
        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
        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)
{
Damien Fouilleul's avatar
Damien Fouilleul committed
60 61 62
    if( NULL == pctInfo )
        return E_INVALIDARG;

63 64 65 66 67 68 69 70
    if( SUCCEEDED(getTypeInfo()) )
        *pctInfo = 1;
    else
        *pctInfo = 0;

    return NOERROR;
};

71
STDMETHODIMP VLCControl::GetTypeInfo(UINT, LCID, LPTYPEINFO* ppTInfo)
72 73 74 75 76 77 78 79
{
    if( NULL == ppTInfo )
        return E_INVALIDARG;

    if( SUCCEEDED(getTypeInfo()) )
    {
        _p_typeinfo->AddRef();
        *ppTInfo = _p_typeinfo;
80
        return NOERROR;
81 82 83 84 85
    }
    *ppTInfo = NULL;
    return E_NOTIMPL;
};

86 87
STDMETHODIMP VLCControl::GetIDsOfNames(REFIID, LPOLESTR* rgszNames,
        UINT cNames, LCID, DISPID* rgDispID)
88 89 90 91 92 93 94 95
{
    if( SUCCEEDED(getTypeInfo()) )
    {
        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
    }
    return E_NOTIMPL;
};

96 97
STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID,
        LCID, WORD wFlags, DISPPARAMS* pDispParams,
98 99 100 101 102 103 104 105 106 107 108 109 110
        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 )
Damien Fouilleul's avatar
Damien Fouilleul committed
111
        return E_POINTER;
112

113
    *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
114

115
    return S_OK;
116
};
117

118 119 120 121
STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
{
    _p_instance->setVisible(isVisible != VARIANT_FALSE);

122
    return S_OK;
123 124 125 126
};

STDMETHODIMP VLCControl::play(void)
{
127 128
    _p_instance->get_player().play();

129
    return S_OK;
130
};
131

132 133
STDMETHODIMP VLCControl::pause(void)
{
134 135 136
    _p_instance->get_player().pause();

    return S_OK;
137
};
138

139 140
STDMETHODIMP VLCControl::stop(void)
{
141 142 143
    _p_instance->get_player().stop();

    return S_OK;
144
};
145

146 147 148
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
{
    if( NULL == isPlaying )
Damien Fouilleul's avatar
Damien Fouilleul committed
149
        return E_POINTER;
150

151 152 153 154
    vlc_player& p = _p_instance->get_player();
    *isPlaying = p.is_playing() ? VARIANT_TRUE : VARIANT_FALSE;

    return S_OK;
155
};
156

157 158 159
STDMETHODIMP VLCControl::get_Position(float *position)
{
    if( NULL == position )
Damien Fouilleul's avatar
Damien Fouilleul committed
160
        return E_POINTER;
161

162 163 164
    *position = _p_instance->get_player().get_position();

    return S_OK;
165
};
166

167 168
STDMETHODIMP VLCControl::put_Position(float position)
{
169 170 171
    _p_instance->get_player().set_position(position);

    return S_OK;
172
};
173

174 175 176
STDMETHODIMP VLCControl::get_Time(int *seconds)
{
    if( NULL == seconds )
Damien Fouilleul's avatar
Damien Fouilleul committed
177
        return E_POINTER;
178

179 180 181
    *seconds = static_cast<int>(_p_instance->get_player().get_time());

    return S_OK;
182
};
183

184 185
STDMETHODIMP VLCControl::put_Time(int seconds)
{
186
    /* setTime function of the plugin sets the time. */
187
    _p_instance->setTime(seconds);
188
    return S_OK;
189
};
190

191 192
STDMETHODIMP VLCControl::shuttle(int seconds)
{
193
    _p_instance->get_player().set_time(seconds);
194

195
    return S_OK;
196
};
197

198 199
STDMETHODIMP VLCControl::fullscreen(void)
{
200 201 202
    _p_instance->toggleFullscreen();

    return S_OK;
203
};
204

205 206 207
STDMETHODIMP VLCControl::get_Length(int *seconds)
{
    if( NULL == seconds )
Damien Fouilleul's avatar
Damien Fouilleul committed
208
        return E_POINTER;
209

210
    *seconds = static_cast<int>(_p_instance->get_player().get_length());
211

212
    return S_OK;
213
};
214

215 216
STDMETHODIMP VLCControl::playFaster(void)
{
217
    _p_instance->get_player().set_rate(2.f);
218

219
    return S_OK;
220
};
221

222 223
STDMETHODIMP VLCControl::playSlower(void)
{
224
    _p_instance->get_player().set_rate(0.5f);
225

226
    return S_OK;
227
};
228

229 230 231
STDMETHODIMP VLCControl::get_Volume(int *volume)
{
    if( NULL == volume )
Damien Fouilleul's avatar
Damien Fouilleul committed
232
        return E_POINTER;
233

234
    *volume  = _p_instance->getVolume();
235
    return S_OK;
236
};
237

238 239
STDMETHODIMP VLCControl::put_Volume(int volume)
{
240
    _p_instance->setVolume(volume);
241
    return S_OK;
242
};
243

244 245
STDMETHODIMP VLCControl::toggleMute(void)
{
246 247 248
    _p_instance->get_player().toggle_mute();

    return S_OK;
249 250
};

251
STDMETHODIMP VLCControl::setVariable(BSTR, VARIANT)
252
{
253 254 255 256 257 258 259 260 261
    libvlc_instance_t* p_libvlc;
    HRESULT result = _p_instance->getVLC(&p_libvlc);
    if( SUCCEEDED(result) )
    {
        _p_instance->setErrorInfo(IID_IVLCControl,
            "setVariable() is an unsafe interface to use. "
            "It has been removed because of security implications." );
    }
    return E_FAIL;
262 263
};

264
STDMETHODIMP VLCControl::getVariable(BSTR, VARIANT *)
265
{
266 267 268 269 270 271 272 273 274
    libvlc_instance_t* p_libvlc;
    HRESULT result = _p_instance->getVLC(&p_libvlc);
    if( SUCCEEDED(result) )
    {
        _p_instance->setErrorInfo(IID_IVLCControl,
            "getVariable() is an unsafe interface to use. "
            "It has been removed because of security implications." );
    }
    return E_FAIL;
275 276
};

277
void VLCControl::FreeTargetOptions(char **cOptions, int cOptionCount)
278
{
279
    // clean up
280
    if( NULL != cOptions )
281
    {
282 283 284 285 286 287 288 289 290
        for( int pos=0; pos<cOptionCount; ++pos )
        {
            char *cOption = cOptions[pos];
            if( NULL != cOption )
                CoTaskMemFree(cOption);
            else
                break;
        }
        CoTaskMemFree(cOptions);
291 292 293
    }
};

294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
static HRESULT parseStringOptions(int codePage, BSTR bstr, char*** cOptions, int *cOptionCount)
{
    HRESULT hr = E_INVALIDARG;
    if( SysStringLen(bstr) > 0 )
    {
        hr = E_OUTOFMEMORY;
        char *s = CStrFromBSTR(codePage, bstr);
        char *val = s;
        if( val )
        {
            long capacity = 16;
            char **options = (char **)CoTaskMemAlloc(capacity*sizeof(char *));
            if( options )
            {
                int nOptions = 0;

                char *end = val + strlen(val);
                while( val < end )
                {
                    // skip leading blanks
                    while( (val < end)
                        && ((*val == ' ' ) || (*val == '\t')) )
                        ++val;

                    char *start = val;
                    // skip till we get a blank character
                    while( (val < end)
                        && (*val != ' ' )
                        && (*val != '\t') )
                    {
                        char c = *(val++);
                        if( ('\'' == c) || ('"' == c) )
                        {
                            // skip till end of string
                            while( (val < end) && (*(val++) != c ) );
                        }
                    }

                    if( val > start )
                    {
                        if( nOptions == capacity )
                        {
                            capacity += 16;
337
                            char **moreOptions = (char **)CoTaskMemRealloc(options, capacity*sizeof(char*));
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
                            if( ! moreOptions )
                            {
                                /* failed to allocate more memory */
                                CoTaskMemFree(s);
                                /* return what we got so far */
                                *cOptionCount = nOptions;
                                *cOptions = options;
                                return NOERROR;
                            }
                            options = moreOptions;
                        }
                        *(val++) = '\0';
                        options[nOptions] = (char *)CoTaskMemAlloc(val-start);
                        if( options[nOptions] )
                        {
                            memcpy(options[nOptions], start, val-start);
                            ++nOptions;
                        }
                        else
                        {
                            /* failed to allocate memory */
                            CoTaskMemFree(s);
                            /* return what we got so far */
                            *cOptionCount = nOptions;
                            *cOptions = options;
                            return NOERROR;
                        }
                    }
                    else
                        // must be end of string
                        break;
                }
                *cOptionCount = nOptions;
                *cOptions = options;
                hr = NOERROR;
            }
            CoTaskMemFree(s);
        }
    }
    return hr;
}

380
HRESULT VLCControl::CreateTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount)
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
{
    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) )
    {
402
        // if object is a collection, retrieve enumerator
403 404 405 406 407 408 409 410 411 412 413 414 415
        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;

416
                *cOptions = (char **)CoTaskMemAlloc(capacity*sizeof(char *));
417 418 419 420 421 422 423 424 425 426 427 428 429 430
                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 )
                                {
431
                                    char **moreOptions = (char **)CoTaskMemRealloc(*cOptions, (capacity+16)*sizeof(char *));
432 433 434 435 436 437 438 439 440 441 442
                                    if( NULL != moreOptions )
                                    {
                                        ZeroMemory(moreOptions+capacity, sizeof(char *)*16);
                                        capacity += 16;
                                        *cOptions = moreOptions;
                                    }
                                    else
                                        hr = E_OUTOFMEMORY;
                                }
                            }
                            else
443 444
                                hr = ( SysStringLen(V_BSTR(&option)) > 0 ) ?
                                    E_OUTOFMEMORY : E_INVALIDARG;
445 446 447 448 449 450 451 452 453 454
                        }
                        else
                            hr = E_INVALIDARG;

                        VariantClear(&option);
                    }
                    *cOptionCount = pos;
                    if( FAILED(hr) )
                    {
                        // free already processed elements
455
                        FreeTargetOptions(*cOptions, *cOptionCount);
456 457 458 459
                    }
                }
                else
                    hr = E_OUTOFMEMORY;
460

461 462 463
                enumVar->Release();
            }
        }
464 465 466 467 468 469 470 471 472 473 474 475
        else
        {
            // coerce object into a string and parse it
            VARIANT v_name;
            VariantInit(&v_name);
            hr = VariantChangeType(&v_name, options, 0, VT_BSTR);
            if( SUCCEEDED(hr) )
            {
                hr = parseStringOptions(codePage, V_BSTR(&v_name), cOptions, cOptionCount);
                VariantClear(&v_name);
            }
        }
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
    }
    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
491
        if( uBound >= lBound )
492 493
        {
            VARTYPE vType;
494
            hr = SafeArrayGetVartype(array, &vType);
495 496 497 498 499 500 501 502
            if( FAILED(hr) )
                return hr;

            long pos;

            // marshall options into an array of C strings
            if( VT_VARIANT == vType )
            {
503
                *cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
504
                if( NULL == *cOptions )
505 506
                    return E_OUTOFMEMORY;

507 508
                ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
                for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
509 510 511 512 513
                {
                    VARIANT option;
                    hr = SafeArrayGetElement(array, &pos, &option);
                    if( SUCCEEDED(hr) )
                    {
514
                        if( VT_BSTR == V_VT(&option) )
515 516 517 518
                        {
                            char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));
                            (*cOptions)[pos-lBound] = cOption;
                            if( NULL == cOption )
519 520
                                hr = ( SysStringLen(V_BSTR(&option)) > 0 ) ?
                                    E_OUTOFMEMORY : E_INVALIDARG;
521 522 523 524 525 526 527 528 529
                        }
                        else
                            hr = E_INVALIDARG;
                        VariantClear(&option);
                    }
                }
            }
            else if( VT_BSTR == vType )
            {
530
                *cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
531
                if( NULL == *cOptions )
532 533
                    return E_OUTOFMEMORY;

534 535
                ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
                for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
536 537 538 539 540 541
                {
                    BSTR option;
                    hr = SafeArrayGetElement(array, &pos, &option);
                    if( SUCCEEDED(hr) )
                    {
                        char *cOption = CStrFromBSTR(codePage, option);
542

543 544
                        (*cOptions)[pos-lBound] = cOption;
                        if( NULL == cOption )
545 546
                            hr = ( SysStringLen(option) > 0 ) ?
                                E_OUTOFMEMORY : E_INVALIDARG;
547 548 549 550
                        SysFreeString(option);
                    }
                }
            }
551
            else
552
            {
553 554
                // unsupported type
                return E_INVALIDARG;
555
            }
556 557 558 559 560

            *cOptionCount = pos-lBound;
            if( FAILED(hr) )
            {
                // free already processed elements
561
                FreeTargetOptions(*cOptions, *cOptionCount);
562 563 564 565 566 567 568 569 570 571
            }
        }
        else
        {
            // empty array
            *cOptions = NULL;
            *cOptionCount = 0;
            return NOERROR;
        }
    }
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
    else if( VT_UNKNOWN == V_VT(options) )
    {
        // coerce object into a string and parse it
        VARIANT v_name;
        VariantInit(&v_name);
        hr = VariantChangeType(&v_name, options, 0, VT_BSTR);
        if( SUCCEEDED(hr) )
        {
            hr = parseStringOptions(codePage, V_BSTR(&v_name), cOptions, cOptionCount);
            VariantClear(&v_name);
        }
    }
    else if( VT_BSTR == V_VT(options) )
    {
        hr = parseStringOptions(codePage, V_BSTR(options), cOptions, cOptionCount);
    }
588 589 590 591 592 593 594 595
    return hr;
};

/*
** use VARIANT rather than a SAFEARRAY as argument type
** for compatibility with some scripting language (JScript)
*/

596
STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position)
597
{
Damien Fouilleul's avatar
Damien Fouilleul committed
598
    if( 0 == SysStringLen(uri) )
599 600
        return E_INVALIDARG;

601 602
    libvlc_instance_t *p_libvlc;
    HRESULT hr = _p_instance->getVLC(&p_libvlc);
603
    if( SUCCEEDED(hr) )
604
    {
605
        char *cUri = CStrFromBSTR(CP_UTF8, uri);
606 607 608 609 610 611
        if( NULL == cUri )
            return E_OUTOFMEMORY;

        int cOptionsCount;
        char **cOptions;

612
        if( FAILED(CreateTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
613 614
            return E_INVALIDARG;

JP Dinger's avatar
JP Dinger committed
615
        position = _p_instance->playlist_add_extended_untrusted(cUri,
616
                       cOptionsCount, const_cast<const char**>(cOptions));
617 618 619 620

        FreeTargetOptions(cOptions, cOptionsCount);
        CoTaskMemFree(cUri);

621
        if( position >= 0 )
622 623 624 625 626
        {
            if( mode & VLCPlayListAppendAndGo )
                _p_instance->fireOnPlayEvent();
        }
        else
627
        {
628
            if( mode & VLCPlayListAppendAndGo )
629 630
                _p_instance->fireOnStopEvent();
        }
631 632 633
    }
    return hr;
};
634

635 636 637
STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
{
    if( NULL == index )
Damien Fouilleul's avatar
Damien Fouilleul committed
638
        return E_POINTER;
639

640 641 642
    *index = _p_instance->get_player().current_item();

    return S_OK;
643
};
644

645 646
STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
{
647 648 649
    if( NULL == count )
        return E_POINTER;

650 651
    *count = _p_instance->get_player().items_count();

652
    return S_OK;
653
};
654

655 656
STDMETHODIMP VLCControl::playlistNext(void)
{
657 658 659
    _p_instance->get_player().next();

    return S_OK;
660
};
661

662 663
STDMETHODIMP VLCControl::playlistPrev(void)
{
664 665 666
    _p_instance->get_player().prev();

    return S_OK;
667
};
668

669 670
STDMETHODIMP VLCControl::playlistClear(void)
{
671 672 673
    _p_instance->get_player().clear_items();

    return S_OK;
674
};
675

676 677 678
STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
{
    if( NULL == version )
Damien Fouilleul's avatar
Damien Fouilleul committed
679
        return E_POINTER;
680

681
    const char *versionStr = libvlc_get_version();
682 683
    if( NULL != versionStr )
    {
684
        *version = BSTRFromCStr(CP_UTF8, versionStr);
685
        return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
686 687 688 689
    }
    *version = NULL;
    return E_FAIL;
};
690

691 692 693 694 695
STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
{
    if( NULL == mrl )
        return E_POINTER;

696 697
    *mrl = SysAllocStringLen(_p_instance->getMRL(),
                SysStringLen(_p_instance->getMRL()));
698
    return S_OK;
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
};

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;
};