+ *ppTInfo = NULL;
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessages::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+ UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessages::Invoke(DISPID dispIdMember, REFIID riid,
+ LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+ VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+ pVarResult, pExcepInfo, puArgErr);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
+{
+ if( NULL == _NewEnum )
+ return E_POINTER;
+
+ IVLCMessageIterator* iter = NULL;
+ iterator(&iter);
+
+ *_NewEnum= new VLCEnumIterator<IID_IEnumVARIANT,
+ IEnumVARIANT,
+ VARIANT,
+ VLCMessageSTLIterator>
+ (VLCMessageSTLIterator(iter), VLCMessageSTLIterator(NULL));
+
+ return *_NewEnum ? S_OK : E_OUTOFMEMORY;
+};
+
+STDMETHODIMP VLCMessages::clear()
+{
+ libvlc_log_t *p_log = _p_vlclog->_p_log;
+ if( p_log )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_log_clear(p_log, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCMessages, libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ }
+ return NOERROR;
+};
+
+STDMETHODIMP VLCMessages::get_count(long* count)
+{
+ if( NULL == count )
+ return E_POINTER;
+
+ libvlc_log_t *p_log = _p_vlclog->_p_log;
+ if( p_log )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ *count = libvlc_log_count(p_log, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCMessages, libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ }
+ else
+ *count = 0;
+ return S_OK;
+};
+
+STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
+{
+ if( NULL == iter )
+ return E_POINTER;
+
+ *iter = new VLCMessageIterator(_p_instance, _p_vlclog);
+
+ return *iter ? S_OK : E_OUTOFMEMORY;
+};
+
+/*******************************************************************************/
+
+VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) :
+ _p_instance(p_instance),
+ _p_typeinfo(NULL),
+ _refcount(1),
+ _p_vlclog(p_vlclog)
+{
+ if( p_vlclog->_p_log )
+ {
+ _p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
+ }
+ else
+ _p_iter = NULL;
+};
+
+VLCMessageIterator::~VLCMessageIterator()
+{
+ if( _p_iter )
+ libvlc_log_iterator_free(_p_iter, NULL);
+
+ if( _p_typeinfo )
+ _p_typeinfo->Release();
+};
+
+HRESULT VLCMessageIterator::loadTypeInfo(void)
+{
+ HRESULT hr = NOERROR;
+ if( NULL == _p_typeinfo )
+ {
+ ITypeLib *p_typelib;
+
+ hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+ if( SUCCEEDED(hr) )
+ {
+ hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessageIterator, &_p_typeinfo);
+ if( FAILED(hr) )
+ {
+ _p_typeinfo = NULL;
+ }
+ p_typelib->Release();
+ }
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCMessageIterator::GetTypeInfoCount(UINT* pctInfo)
+{
+ if( NULL == pctInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ *pctInfo = 1;
+ else
+ *pctInfo = 0;
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCMessageIterator::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+ if( NULL == ppTInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ _p_typeinfo->AddRef();
+ *ppTInfo = _p_typeinfo;
+ return NOERROR;
+ }
+ *ppTInfo = NULL;
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessageIterator::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+ UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
+ LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+ VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+ pVarResult, pExcepInfo, puArgErr);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
+{
+ if( NULL == hasNext )
+ return E_POINTER;
+
+ if( _p_iter && _p_vlclog->_p_log )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ }
+ else
+ {
+ *hasNext = VARIANT_FALSE;
+ }
+ return S_OK;
+};
+
+STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
+{
+ if( NULL == message )
+ return E_POINTER;
+
+ if( _p_iter && _p_vlclog->_p_log )
+ {
+ struct libvlc_log_message_t buffer;
+
+ buffer.sizeof_msg = sizeof(buffer);
+
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_log_iterator_next(_p_iter, &buffer, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ *message = new VLCMessage(_p_instance, buffer);
+ return *message ? NOERROR : E_OUTOFMEMORY;
+ }
+ return E_FAIL;
+};
+
+/*******************************************************************************/
+
+VLCMessage::~VLCMessage()
+{
+ if( _p_typeinfo )
+ _p_typeinfo->Release();
+};
+
+HRESULT VLCMessage::loadTypeInfo(void)
+{
+ HRESULT hr = NOERROR;
+ if( NULL == _p_typeinfo )
+ {
+ ITypeLib *p_typelib;
+
+ hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+ if( SUCCEEDED(hr) )
+ {
+ hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessage, &_p_typeinfo);
+ if( FAILED(hr) )
+ {
+ _p_typeinfo = NULL;
+ }
+ p_typelib->Release();
+ }
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCMessage::GetTypeInfoCount(UINT* pctInfo)
+{
+ if( NULL == pctInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ *pctInfo = 1;
+ else
+ *pctInfo = 0;
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+ if( NULL == ppTInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ _p_typeinfo->AddRef();
+ *ppTInfo = _p_typeinfo;
+ return NOERROR;
+ }
+ *ppTInfo = NULL;
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessage::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+ UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessage::Invoke(DISPID dispIdMember, REFIID riid,
+ LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+ VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+ pVarResult, pExcepInfo, puArgErr);
+ }
+ return E_NOTIMPL;
+};
+
+inline const char *msgSeverity(int sev)
+{
+ switch( sev )
+ {
+ case 0:
+ return "info";
+ case 1:
+ return "error";
+ case 2:
+ return "warning";
+ default:
+ return "debug";
+ }
+};
+
+STDMETHODIMP VLCMessage::get__Value(VARIANT* _Value)
+{
+ if( NULL == _Value )
+ return E_POINTER;
+
+ char buffer[256];
+
+ snprintf(buffer, sizeof(buffer), "%s %s %s: %s",
+ _msg.psz_type, _msg.psz_name, msgSeverity(_msg.i_severity), _msg.psz_message);
+
+ V_VT(_Value) = VT_BSTR;
+ V_BSTR(_Value) = BSTRFromCStr(CP_UTF8, buffer);
+
+ return S_OK;
+};
+
+STDMETHODIMP VLCMessage::get_severity(long* level)
+{
+ if( NULL == level )
+ return E_POINTER;
+
+ *level = _msg.i_severity;
+
+ return S_OK;
+};
+
+STDMETHODIMP VLCMessage::get_type(BSTR* type)
+{
+ if( NULL == type )
+ return E_POINTER;
+
+ *type = BSTRFromCStr(CP_UTF8, _msg.psz_type);
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::get_name(BSTR* name)
+{
+ if( NULL == name )
+ return E_POINTER;
+
+ *name = BSTRFromCStr(CP_UTF8, _msg.psz_name);
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::get_header(BSTR* header)
+{
+ if( NULL == header )
+ return E_POINTER;
+
+ *header = BSTRFromCStr(CP_UTF8, _msg.psz_header);
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::get_message(BSTR* message)
+{
+ if( NULL == message )
+ return E_POINTER;
+
+ *message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
+
+ return NOERROR;
+};
+
+/*******************************************************************************/
+
+VLCPlaylistItems::~VLCPlaylistItems()
+{
+ if( _p_typeinfo )
+ _p_typeinfo->Release();
+};
+
+HRESULT VLCPlaylistItems::loadTypeInfo(void)
+{
+ HRESULT hr = NOERROR;
+ if( NULL == _p_typeinfo )
+ {
+ ITypeLib *p_typelib;
+
+ hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+ if( SUCCEEDED(hr) )
+ {
+ hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylistItems, &_p_typeinfo);
+ if( FAILED(hr) )
+ {
+ _p_typeinfo = NULL;
+ }
+ p_typelib->Release();
+ }
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylistItems::GetTypeInfoCount(UINT* pctInfo)
+{
+ if( NULL == pctInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ *pctInfo = 1;
+ else
+ *pctInfo = 0;
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCPlaylistItems::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+ if( NULL == ppTInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ _p_typeinfo->AddRef();
+ *ppTInfo = _p_typeinfo;
+ return NOERROR;
+ }
+ *ppTInfo = NULL;
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylistItems::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+ UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylistItems::Invoke(DISPID dispIdMember, REFIID riid,
+ LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+ VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+ pVarResult, pExcepInfo, puArgErr);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylistItems::get_count(long* count)
+{
+ if( NULL == count )
+ return E_POINTER;
+
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ *count = libvlc_playlist_items_count(p_libvlc, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylistItems::clear()
+{
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_playlist_clear(p_libvlc, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylistItems::remove(long item)
+{
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_playlist_delete_item(p_libvlc, item, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+/*******************************************************************************/
+
+VLCPlaylist::~VLCPlaylist()
+{
+ delete _p_vlcplaylistitems;
+ if( _p_typeinfo )
+ _p_typeinfo->Release();
+};
+
+HRESULT VLCPlaylist::loadTypeInfo(void)
+{
+ HRESULT hr = NOERROR;
+ if( NULL == _p_typeinfo )
+ {
+ ITypeLib *p_typelib;
+
+ hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+ if( SUCCEEDED(hr) )
+ {
+ hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylist, &_p_typeinfo);
+ if( FAILED(hr) )
+ {
+ _p_typeinfo = NULL;
+ }
+ p_typelib->Release();
+ }
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylist::GetTypeInfoCount(UINT* pctInfo)
+{
+ if( NULL == pctInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ *pctInfo = 1;
+ else
+ *pctInfo = 0;
+
+ return NOERROR;
+};
+
+STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+ if( NULL == ppTInfo )
+ return E_INVALIDARG;
+
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ _p_typeinfo->AddRef();
+ *ppTInfo = _p_typeinfo;
+ return NOERROR;
+ }
+ *ppTInfo = NULL;
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+ UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
+ LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+ VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+ if( SUCCEEDED(loadTypeInfo()) )
+ {
+ return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+ pVarResult, pExcepInfo, puArgErr);
+ }
+ return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
+{
+ if( NULL == count )
+ return E_POINTER;
+
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ *count = libvlc_playlist_items_count(p_libvlc, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylist,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
+{
+ if( NULL == isPlaying )
+ return E_POINTER;
+
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ *isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ? VARIANT_TRUE: VARIANT_FALSE;
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylist,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* item)
+{
+ if( NULL == item )
+ return E_POINTER;
+
+ if( 0 == SysStringLen(uri) )
+ return E_INVALIDARG;
+
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ char *psz_uri = NULL;
+ if( SysStringLen(_p_instance->getBaseURL()) > 0 )
+ {
+ /*
+ ** if the MRL a relative URL, we should end up with an absolute URL
+ */
+ LPWSTR abs_url = CombineURL(_p_instance->getBaseURL(), uri);
+ if( NULL != abs_url )
+ {
+ psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
+ CoTaskMemFree(abs_url);
+ }
+ else
+ {
+ psz_uri = CStrFromBSTR(CP_UTF8, uri);
+ }
+ }
+ else
+ {
+ /*
+ ** baseURL is empty, assume MRL is absolute
+ */
+ psz_uri = CStrFromBSTR(CP_UTF8, uri);
+ }
+
+ if( NULL == psz_uri )
+ {
+ return E_OUTOFMEMORY;
+ }
+
+ int i_options;
+ char **ppsz_options;
+
+ hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
+ if( FAILED(hr) )
+ {
+ CoTaskMemFree(psz_uri);
+ return hr;
+ }
+
+ char *psz_name = NULL;
+ VARIANT v_name;
+ VariantInit(&v_name);
+ if( SUCCEEDED(VariantChangeType(&v_name, &name, 0, VT_BSTR)) )
+ {
+ if( SysStringLen(V_BSTR(&v_name)) > 0 )
+ psz_name = CStrFromBSTR(CP_UTF8, V_BSTR(&v_name));
+
+ VariantClear(&v_name);
+ }
+
+ *item = libvlc_playlist_add_extended(p_libvlc,
+ psz_uri,
+ psz_name,
+ i_options,
+ const_cast<const char **>(ppsz_options),
+ &ex);
+
+ VLCControl::FreeTargetOptions(ppsz_options, i_options);
+ CoTaskMemFree(psz_uri);
+ if( psz_name )
+ CoTaskMemFree(psz_name);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylist,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylist::play()
+{
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylist::playItem(long item)
+{
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylist,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;
+};
+
+STDMETHODIMP VLCPlaylist::togglePause()
+{
+ libvlc_instance_t* p_libvlc;
+ HRESULT hr = _p_instance->getVLC(&p_libvlc);
+ if( SUCCEEDED(hr) )
+ {
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
+
+ libvlc_playlist_pause(p_libvlc, &ex);
+ if( libvlc_exception_raised(&ex) )
+ {
+ _p_instance->setErrorInfo(IID_IVLCPlaylist,
+ libvlc_exception_get_message(&ex));
+ libvlc_exception_clear(&ex);
+ return E_FAIL;
+ }
+ return NOERROR;
+ }
+ return hr;