]> git.sesse.net Git - vlc/blobdiff - projects/activex/vlccontrol2.cpp
ActiveX: Improve subtitle and audio track JS bindings
[vlc] / projects / activex / vlccontrol2.cpp
index 26548c0ac026e033e8ee0ab5b20188e69ad9f596..daebef7d854814f04855c78732e1ee0f1e83c00b 100644 (file)
@@ -16,9 +16,9 @@
  * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * 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.
  *****************************************************************************/
 
 #include "plugin.h"
 
 #include "utils.h"
 
+#include <stdio.h>
 #include <shlwapi.h>
 #include <wininet.h>
 #include <tchar.h>
 
-using namespace std;
+
+static inline
+HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
+{
+    if( libvlc_exception_raised(ex) )
+    {
+        p->setErrorInfo(riid,libvlc_exception_get_message(ex));
+        libvlc_exception_clear(ex);
+        return E_FAIL;
+    }
+    return NOERROR;
+}
+
+#define EMIT_EXCEPTION_BRIDGE( classname ) \
+    HRESULT classname::exception_bridge( libvlc_exception_t *ex ) \
+    { return _exception_bridge( _p_instance, IID_I##classname, ex ); }
+
+EMIT_EXCEPTION_BRIDGE( VLCAudio )
+EMIT_EXCEPTION_BRIDGE( VLCInput )
+EMIT_EXCEPTION_BRIDGE( VLCMessageIterator )
+EMIT_EXCEPTION_BRIDGE( VLCMessages )
+EMIT_EXCEPTION_BRIDGE( VLCLog )
+EMIT_EXCEPTION_BRIDGE( VLCPlaylistItems )
+EMIT_EXCEPTION_BRIDGE( VLCPlaylist )
+EMIT_EXCEPTION_BRIDGE( VLCVideo )
+
+#undef  EMIT_EXCEPTION_BRIDGE
+
 
 VLCAudio::~VLCAudio()
 {
@@ -122,14 +150,9 @@ STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        *mute = libvlc_audio_get_mute(p_libvlc, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        *mute = libvlc_audio_get_mute(p_libvlc, &ex) ?
+                        VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -144,13 +167,7 @@ STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
         libvlc_exception_init(&ex);
 
         libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -168,13 +185,7 @@ STDMETHODIMP VLCAudio::get_volume(long* volume)
         libvlc_exception_init(&ex);
 
         *volume = libvlc_audio_get_volume(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -189,14 +200,7 @@ STDMETHODIMP VLCAudio::put_volume(long volume)
         libvlc_exception_init(&ex);
 
         libvlc_audio_set_volume(p_libvlc, volume, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                         libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -206,40 +210,47 @@ STDMETHODIMP VLCAudio::get_track(long* track)
     if( NULL == track )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t* p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
         *track = libvlc_audio_get_track(p_md, &ex);
-        libvlc_media_player_release(p_md);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                         libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCAudio::put_track(long track)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
         libvlc_audio_set_track(p_md, track, &ex);
-        libvlc_media_player_release(p_md);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCAudio::get_count(long* trackNumber)
+{
+    if( NULL == trackNumber )
+        return E_POINTER;
+
+    libvlc_media_player_t* p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+        // get the number of audio track available and return it
+        *trackNumber = libvlc_audio_get_track_count(p_md, &ex);
         if( libvlc_exception_raised(&ex) )
         {
             _p_instance->setErrorInfo(IID_IVLCAudio,
@@ -252,6 +263,65 @@ STDMETHODIMP VLCAudio::put_track(long track)
     return hr;
 };
 
+
+STDMETHODIMP VLCAudio::description(long trackID, BSTR* name)
+{
+    if( NULL == name )
+        return E_POINTER;
+
+    libvlc_media_player_t* p_md;
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        int i, i_limit;
+        const char *psz_name;
+        libvlc_track_description_t *p_trackDesc;
+
+        // get tracks description
+        p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
+        if(  libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+
+        //get the number of available track
+        i_limit = libvlc_audio_get_track_count(p_md, &ex);
+        if(  libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+
+        // check if the number given is a good one
+        if ( ( trackID > ( i_limit -1 ) ) || ( trackID < 0 ) )
+                return E_FAIL;
+
+        // get the good trackDesc
+        for( i = 0 ; i < trackID ; i++ )
+        {
+            p_trackDesc = p_trackDesc->p_next;
+        }
+        // get the track name
+        psz_name = p_trackDesc->psz_name;
+
+        // return it
+        if( psz_name != NULL )
+        {
+            *name = BSTRFromCStr(CP_UTF8, psz_name);
+            return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
+        }
+        *name = NULL;
+        return E_FAIL;
+    }
+    return hr;
+};
+
 STDMETHODIMP VLCAudio::get_channel(long *channel)
 {
     if( NULL == channel )
@@ -265,14 +335,7 @@ STDMETHODIMP VLCAudio::get_channel(long *channel)
         libvlc_exception_init(&ex);
 
         *channel = libvlc_audio_get_channel(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                        libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -287,14 +350,7 @@ STDMETHODIMP VLCAudio::put_channel(long channel)
         libvlc_exception_init(&ex);
 
         libvlc_audio_set_channel(p_libvlc, channel, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                         libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -309,14 +365,7 @@ STDMETHODIMP VLCAudio::toggleMute()
         libvlc_exception_init(&ex);
 
         libvlc_audio_toggle_mute(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                         libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -404,27 +453,17 @@ STDMETHODIMP VLCInput::get_length(double* length)
 {
     if( NULL == length )
         return E_POINTER;
+    *length = 0;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *length = (double)libvlc_media_player_get_length(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *length = (double)libvlc_media_player_get_length(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -434,52 +473,31 @@ STDMETHODIMP VLCInput::get_position(double* position)
     if( NULL == position )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    *position = 0.0f;
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *position = libvlc_media_player_get_position(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *position = libvlc_media_player_get_position(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCInput::put_position(double position)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_media_player_set_position(p_md, position, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_media_player_set_position(p_md, position, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -489,52 +507,30 @@ STDMETHODIMP VLCInput::get_time(double* time)
     if( NULL == time )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *time = (double)libvlc_media_player_get_time(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *time = (double)libvlc_media_player_get_time(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCInput::put_time(double time)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_media_player_set_time(p_md, (vlc_int64_t)time, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_media_player_set_time(p_md, (int64_t)time, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -544,22 +540,17 @@ STDMETHODIMP VLCInput::get_state(long* state)
     if( NULL == state )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
+        *state = libvlc_media_player_get_state(p_md, &ex);
         if( ! libvlc_exception_raised(&ex) )
         {
-            *state = libvlc_media_player_get_state(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
+            return NOERROR;
         }
         libvlc_exception_clear(&ex);
         // don't fail, just return the idle state
@@ -574,52 +565,30 @@ STDMETHODIMP VLCInput::get_rate(double* rate)
     if( NULL == rate )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *rate = libvlc_media_player_get_rate(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *rate = libvlc_media_player_get_rate(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCInput::put_rate(double rate)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_media_player_set_rate(p_md, rate, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_media_player_set_rate(p_md, rate, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -630,26 +599,15 @@ STDMETHODIMP VLCInput::get_fps(double* fps)
         return E_POINTER;
 
     *fps = 0.0;
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *fps = libvlc_media_player_get_fps(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *fps = libvlc_media_player_get_fps(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -659,26 +617,16 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
     if( NULL == hasVout )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *hasVout = libvlc_media_player_has_vout(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *hasVout = libvlc_media_player_has_vout(p_md, &ex) ?
+                                VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -795,12 +743,7 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
             libvlc_exception_init(&ex);
 
             *level = libvlc_get_log_verbosity(p_libvlc, &ex);
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
-            }
+            hr = exception_bridge(&ex);
         }
         return hr;
     }
@@ -814,45 +757,30 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
 
 STDMETHODIMP VLCLog::put_verbosity(long verbosity)
 {
-    libvlc_exception_t ex;
-    libvlc_exception_init(&ex);
-
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
     {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
         if( verbosity >= 0 )
         {
             if( ! _p_log )
             {
                 _p_log = libvlc_log_open(p_libvlc, &ex);
-                if( libvlc_exception_raised(&ex) )
-                {
-                    _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
-                    libvlc_exception_clear(&ex);
-                    return E_FAIL;
-                }
-            }
-            libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
+                hr = exception_bridge(&ex);
             }
+            if( SUCCEEDED(hr) )
+                libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
         }
         else if( _p_log )
         {
             /* close log  when verbosity is set to -1 */
             libvlc_log_close(_p_log, &ex);
             _p_log = NULL;
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
-            }
         }
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -917,7 +845,8 @@ public:
         VariantInit(&v);
         if( msg )
         {
-            if( SUCCEEDED(msg->QueryInterface(IID_IDispatch, (LPVOID*)&V_DISPATCH(&v))) )
+            if( SUCCEEDED(msg->QueryInterface(IID_IDispatch,
+                          (LPVOID*)&V_DISPATCH(&v))) )
             {
                 V_VT(&v) = VT_DISPATCH;
             }
@@ -1038,6 +967,7 @@ STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
 
 STDMETHODIMP VLCMessages::clear()
 {
+    HRESULT hr = NOERROR;
     libvlc_log_t *p_log = _p_vlclog->_p_log;
     if( p_log )
     {
@@ -1045,18 +975,15 @@ STDMETHODIMP VLCMessages::clear()
         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;
-        }
+        hr = exception_bridge(&ex);
     }
-    return NOERROR;
+    return hr;
 };
 
 STDMETHODIMP VLCMessages::get_count(long* count)
 {
+    HRESULT hr = S_OK;
+
     if( NULL == count )
         return E_POINTER;
 
@@ -1067,16 +994,11 @@ STDMETHODIMP VLCMessages::get_count(long* count)
         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;
-        }
+        hr = exception_bridge(&ex);
     }
     else
         *count = 0;
-    return S_OK;
+    return hr;
 };
 
 STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
@@ -1187,6 +1109,8 @@ STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
 
 STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
 {
+    HRESULT hr = S_OK;
+
     if( NULL == hasNext )
         return E_POINTER;
 
@@ -1195,23 +1119,21 @@ STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
         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;
-        }
+        *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ?
+                   VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     else
     {
         *hasNext = VARIANT_FALSE;
     }
-    return S_OK;
+    return hr;
 };
 
 STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
 {
+    HRESULT hr = S_OK;
+
     if( NULL == message )
         return E_POINTER;
 
@@ -1225,16 +1147,15 @@ STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
         libvlc_exception_init(&ex);
 
         libvlc_log_iterator_next(_p_iter, &buffer, &ex);
-        if( libvlc_exception_raised(&ex) )
+        hr = exception_bridge(&ex);
+        if( SUCCEEDED(hr) )
         {
-            _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
+            *message = new VLCMessage(_p_instance, buffer);
+            if( !message )
+                hr = E_OUTOFMEMORY;
         }
-        *message = new VLCMessage(_p_instance, buffer);
-        return *message ? NOERROR : E_OUTOFMEMORY;
     }
-    return E_FAIL;
+    return hr;
 };
 
 /*******************************************************************************/
@@ -1481,46 +1402,20 @@ 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);
+    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;
+    *count = _p_instance->playlist_count(&ex);
+    return exception_bridge(&ex);
 };
 
 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_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;
+    _p_instance->playlist_clear(&ex);
+    return exception_bridge(&ex);
 };
 
 STDMETHODIMP VLCPlaylistItems::remove(long item)
@@ -1532,15 +1427,8 @@ STDMETHODIMP VLCPlaylistItems::remove(long item)
         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;
+        _p_instance->playlist_delete_item(item, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -1630,24 +1518,12 @@ 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 = 0;
+    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;
+    *count = _p_instance->playlist_count(&ex);
+    return exception_bridge(&ex);
 };
 
 STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
@@ -1655,22 +1531,16 @@ 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);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     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;
+        *isPlaying = libvlc_media_player_is_playing(p_md, &ex) ?
+                     VARIANT_TRUE: VARIANT_FALSE;
+        libvlc_exception_clear(&ex);
     }
     return hr;
 };
@@ -1741,72 +1611,94 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
             VariantClear(&v_name);
         }
 
-        *item = libvlc_playlist_add_extended(p_libvlc,
-                    psz_uri,
-                    psz_name,
-                    i_options,
-                    const_cast<const char **>(ppsz_options),
-                    &ex);
+        *item = _p_instance->playlist_add_extended_untrusted(psz_uri,
+                    i_options, const_cast<const char **>(ppsz_options), &ex);
 
         VLCControl::FreeTargetOptions(ppsz_options, i_options);
         CoTaskMemFree(psz_uri);
-        if( psz_name )
+        if( psz_name ) /* XXX Do we even need to check? */
             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;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCPlaylist::play()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_play(&ex);
+    return exception_bridge(&ex);
+};
+
+STDMETHODIMP VLCPlaylist::playItem(long item)
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_play_item(item,&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::togglePause()
+{
+    libvlc_media_player_t* p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     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;
+        libvlc_media_player_pause(p_md, &ex);
+        hr = exception_bridge(&ex);;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::playItem(long item)
+STDMETHODIMP VLCPlaylist::stop()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     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;
+        libvlc_media_player_stop(p_md, &ex);
+        hr = exception_bridge(&ex);;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::togglePause()
+STDMETHODIMP VLCPlaylist::next()
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_next(&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::prev()
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_prev(&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::clear()
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_clear(&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::removeItem(long item)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -1815,77 +1707,142 @@ STDMETHODIMP VLCPlaylist::togglePause()
         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;
+        _p_instance->playlist_delete_item(item, &ex);
+        hr = exception_bridge(&ex);;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::stop()
+STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
-    if( SUCCEEDED(hr) )
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcplaylistitems;
+    if( NULL != _p_vlcplaylistitems )
     {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+        _p_vlcplaylistitems->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
 
-        libvlc_playlist_stop(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
+/*******************************************************************************/
+
+VLCSubtitle::~VLCSubtitle()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCSubtitle::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
         {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCSubtitle, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
         }
-        return NOERROR;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::next()
+STDMETHODIMP VLCSubtitle::GetTypeInfoCount(UINT* pctInfo)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCSubtitle::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 VLCSubtitle::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 VLCSubtitle::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 VLCSubtitle::get_track(long* spu)
+{
+    if( NULL == spu )
+        return E_POINTER;
+
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_next(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
+        *spu = libvlc_video_get_spu(p_md, &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 NOERROR;
+        _p_instance->setErrorInfo(IID_IVLCSubtitle, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::prev()
+STDMETHODIMP VLCSubtitle::put_track(long spu)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_prev(p_libvlc, &ex);
+        libvlc_video_set_spu(p_md, spu, &ex);
         if( libvlc_exception_raised(&ex) )
         {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
+            _p_instance->setErrorInfo(IID_IVLCSubtitle, libvlc_exception_get_message(&ex));
             libvlc_exception_clear(&ex);
             return E_FAIL;
         }
@@ -1894,20 +1851,22 @@ STDMETHODIMP VLCPlaylist::prev()
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::clear()
+STDMETHODIMP VLCSubtitle::get_count(long* spuNumber)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( NULL == spuNumber )
+        return E_POINTER;
+
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
-
-        libvlc_playlist_clear(p_libvlc, &ex);
+        // get the number of video subtitle available and return it
+        *spuNumber = libvlc_video_get_spu_count(p_md, &ex);
         if( libvlc_exception_raised(&ex) )
         {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
+           _p_instance->setErrorInfo(IID_IVLCSubtitle, libvlc_exception_get_message(&ex));
             libvlc_exception_clear(&ex);
             return E_FAIL;
         }
@@ -1916,40 +1875,63 @@ STDMETHODIMP VLCPlaylist::clear()
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::removeItem(long item)
+
+STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( NULL == name )
+       return E_POINTER;
+
+    libvlc_media_player_t* p_md;
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+        int i, i_limit;
+        const char *psz_name;
+        libvlc_track_description_t *p_spuDesc;
+
+        // get subtitles description
+        p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
+        if(  libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCSubtitle, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
 
-        libvlc_playlist_delete_item(p_libvlc, item, &ex);
+        // get the number of available subtitle
+        i_limit = libvlc_video_get_spu_count(p_md, &ex);
         if( libvlc_exception_raised(&ex) )
         {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
+            _p_instance->setErrorInfo(IID_IVLCSubtitle, libvlc_exception_get_message(&ex));
             libvlc_exception_clear(&ex);
             return E_FAIL;
         }
-        return NOERROR;
-    }
-    return hr;
-};
 
-STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
-{
-    if( NULL == obj )
-        return E_POINTER;
+        // check if the number given is a good one
+        if ( ( nameID > ( i_limit -1 ) ) || ( nameID < 0 ) )
+            return E_FAIL;
 
-    *obj = _p_vlcplaylistitems;
-    if( NULL != _p_vlcplaylistitems )
-    {
-        _p_vlcplaylistitems->AddRef();
-        return NOERROR;
+        // get the good spuDesc
+        for( i = 0 ; i < nameID ; i++ )
+        {
+            p_spuDesc = p_spuDesc->p_next;
+        }
+        // get the subtitle name
+        psz_name = p_spuDesc->psz_name;
+
+        // return it
+        if( psz_name != NULL )
+        {
+            *name = BSTRFromCStr(CP_UTF8, psz_name);
+            return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
+        }
+        *name = NULL;
+        return E_FAIL;
     }
-    return E_OUTOFMEMORY;
+    return hr;
 };
 
 /*******************************************************************************/
@@ -2036,52 +2018,31 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
     if( NULL == fullscreen )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *fullscreen = libvlc_get_fullscreen(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *fullscreen = libvlc_get_fullscreen(p_md, &ex) ?
+                      VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2091,26 +2052,15 @@ STDMETHODIMP VLCVideo::get_width(long* width)
     if( NULL == width )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *width = libvlc_video_get_width(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *width = libvlc_video_get_width(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2120,26 +2070,15 @@ STDMETHODIMP VLCVideo::get_height(long* height)
     if( NULL == height )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *height = libvlc_video_get_height(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *height = libvlc_video_get_height(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2149,35 +2088,23 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
     if( NULL == aspect )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
-
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                if( NULL == psz_aspect )
-                    return E_OUTOFMEMORY;
+        char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
 
-                *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
-                free( psz_aspect );
-                psz_aspect = NULL;
-                return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
-            }
-            free( psz_aspect );
-            psz_aspect = NULL;
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        hr = exception_bridge(&ex);
+        if( SUCCEEDED(hr) && NULL != psz_aspect )
+        {
+            *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
+            if( NULL == *aspect )
+                hr = E_OUTOFMEMORY;
+        } else if( NULL == psz_aspect) hr = E_OUTOFMEMORY; // strdup("") failed
+        free( psz_aspect );
     }
     return hr;
 };
@@ -2190,35 +2117,23 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
     if( 0 == SysStringLen(aspect) )
         return E_INVALIDARG;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
+        char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
+        if( NULL == psz_aspect )
         {
-            char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
-            if( NULL == psz_aspect )
-            {
-                return E_OUTOFMEMORY;
-            }
+            return E_OUTOFMEMORY;
+        }
 
-            libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
+        libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
 
-            CoTaskMemFree(psz_aspect);
-            libvlc_media_player_release(p_md);
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCVideo,
-                    libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
-            }
-        }
-        return NOERROR;
+        CoTaskMemFree(psz_aspect);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2228,49 +2143,30 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
     if( NULL == spu )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *spu = libvlc_video_get_spu(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *spu = libvlc_video_get_spu(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_subtitle(long spu)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
         libvlc_video_set_spu(p_md, spu, &ex);
-        libvlc_media_player_release(p_md);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2280,35 +2176,22 @@ STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
     if( NULL == geometry )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
-
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                if( NULL == psz_geometry )
-                    return E_OUTOFMEMORY;
+        char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
 
-                *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
-                free( psz_geometry );
-                psz_geometry = NULL;
-                return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
-            }
-            free( psz_geometry );
-            psz_geometry = NULL;
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        hr = exception_bridge(&ex);
+        if( SUCCEEDED(&ex) && NULL != psz_geometry )
+        {
+            *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
+            if( NULL == geometry ) hr = E_OUTOFMEMORY;
+        } else if( NULL == psz_geometry ) hr = E_OUTOFMEMORY;
+        free( psz_geometry );
     }
     return hr;
 };
@@ -2321,35 +2204,23 @@ STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
     if( 0 == SysStringLen(geometry) )
         return E_INVALIDARG;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
+        char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
+        if( NULL == psz_geometry )
         {
-            char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
-            if( NULL == psz_geometry )
-            {
-                return E_OUTOFMEMORY;
-            }
+            return E_OUTOFMEMORY;
+        }
 
-            libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
+        libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
 
-            CoTaskMemFree(psz_geometry);
-            libvlc_media_player_release(p_md);
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCVideo,
-                    libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
-            }
-        }
-        return NOERROR;
+        CoTaskMemFree(psz_geometry);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2359,49 +2230,30 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
     if( NULL == page )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *page = libvlc_video_get_teletext(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *page = libvlc_video_get_teletext(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_teletext(long page)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
         libvlc_video_set_teletext(p_md, page, &ex);
-        libvlc_media_player_release(p_md);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2411,100 +2263,92 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
     if( NULL == picture )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            static int uniqueId = 0;
-            TCHAR path[MAX_PATH+1];
+        static int uniqueId = 0;
+        TCHAR path[MAX_PATH+1];
 
-            int pathlen = GetTempPath(MAX_PATH-24, path);
-            if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
-                return E_FAIL;
+        int pathlen = GetTempPath(MAX_PATH-24, path);
+        if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
+            return E_FAIL;
 
-            /* check temp directory path by openning it */
+        /* check temp directory path by openning it */
+        {
+            HANDLE dirHandle = CreateFile(path, GENERIC_READ,
+                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+                       NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+            if( INVALID_HANDLE_VALUE == dirHandle )
+            {
+                _p_instance->setErrorInfo(IID_IVLCVideo,
+                        "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
+                return E_FAIL;
+            }
+            else
             {
-                HANDLE dirHandle = CreateFile(path,
-                                              GENERIC_READ,
-                                              FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                                              NULL,
-                                              OPEN_EXISTING,
-                                              FILE_FLAG_BACKUP_SEMANTICS, NULL);
-                if( INVALID_HANDLE_VALUE == dirHandle )
+                BY_HANDLE_FILE_INFORMATION bhfi;
+                BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
+                CloseHandle(dirHandle);
+                if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
                 {
                     _p_instance->setErrorInfo(IID_IVLCVideo,
                             "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
                     return E_FAIL;
                 }
-                else
-                {
-                    BY_HANDLE_FILE_INFORMATION bhfi;
-                    BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
-                    CloseHandle(dirHandle);
-                    if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
-                    {
-                        _p_instance->setErrorInfo(IID_IVLCVideo,
-                                "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
-                        return E_FAIL;
-                    }
-                }
             }
+        }
 
-            TCHAR filepath[MAX_PATH+1];
+        TCHAR filepath[MAX_PATH+1];
 
-            _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
-                     path, GetCurrentProcessId(), ++uniqueId);
+        _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
+                 path, GetCurrentProcessId(), ++uniqueId);
 
 #ifdef _UNICODE
-            /* reuse path storage for UTF8 string */
-            char *psz_filepath = (char *)path;
-            WCHAR* wpath = filepath;
+        /* reuse path storage for UTF8 string */
+        char *psz_filepath = (char *)path;
+        WCHAR* wpath = filepath;
 #else
-            char *psz_filepath = path;
-            /* first convert to unicode using current code page */
-            WCHAR wpath[MAX_PATH+1];
-            if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) )
-                return E_FAIL;
+        char *psz_filepath = path;
+        /* first convert to unicode using current code page */
+        WCHAR wpath[MAX_PATH+1];
+        if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) )
+            return E_FAIL;
 #endif
-            /* convert to UTF8 */
-            pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL);
-            // fail if path is 0 or too short (i.e pathlen is the same as storage size)
-            if( (0 == pathlen) || (sizeof(path) == pathlen) )
-                return E_FAIL;
+        /* convert to UTF8 */
+        pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL);
+        // fail if path is 0 or too short (i.e pathlen is the same as storage size)
+        if( (0 == pathlen) || (sizeof(path) == pathlen) )
+            return E_FAIL;
 
-            /* take snapshot into file */
-            libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
+        /* take snapshot into file */
+        libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            hr = E_FAIL;
+            /* open snapshot file */
+            HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
+            if( snapPic )
             {
-                hr = E_FAIL;
-                /* open snapshot file */
-                HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
-                if( snapPic )
+                PICTDESC snapDesc;
+
+                snapDesc.cbSizeofstruct = sizeof(PICTDESC);
+                snapDesc.picType        = PICTYPE_BITMAP;
+                snapDesc.bmp.hbitmap    = (HBITMAP)snapPic;
+                snapDesc.bmp.hpal       = NULL;
+
+                hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture);
+                if( FAILED(hr) )
                 {
-                    PICTDESC snapDesc;
-
-                    snapDesc.cbSizeofstruct = sizeof(PICTDESC);
-                    snapDesc.picType        = PICTYPE_BITMAP;
-                    snapDesc.bmp.hbitmap    = (HBITMAP)snapPic;
-                    snapDesc.bmp.hpal       = NULL;
-
-                    hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture);
-                    if( FAILED(hr) )
-                    {
-                        *picture = NULL;
-                        DeleteObject(snapPic);
-                    }
+                    *picture = NULL;
+                    DeleteObject(snapPic);
                 }
-                DeleteFile(filepath);
-                return hr;
             }
+            DeleteFile(filepath);
+            return hr;
         }
         _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
         libvlc_exception_clear(&ex);
@@ -2515,52 +2359,30 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
 
 STDMETHODIMP VLCVideo::toggleFullscreen()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_toggle_fullscreen(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_toggle_fullscreen(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::toggleTeletext()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_toggle_teletext(p_md, &ex);
-            libvlc_media_player_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_toggle_teletext(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2573,18 +2395,21 @@ VLCControl2::VLCControl2(VLCPlugin *p_instance) :
     _p_vlcaudio(NULL),
     _p_vlcinput(NULL),
     _p_vlcplaylist(NULL),
+    _p_vlcsubtitle(NULL),
     _p_vlcvideo(NULL)
 {
     _p_vlcaudio     = new VLCAudio(p_instance);
     _p_vlcinput     = new VLCInput(p_instance);
     _p_vlclog       = new VLCLog(p_instance);
     _p_vlcplaylist  = new VLCPlaylist(p_instance);
+    _p_vlcsubtitle  = new VLCSubtitle(p_instance);
     _p_vlcvideo     = new VLCVideo(p_instance);
 };
 
 VLCControl2::~VLCControl2()
 {
     delete _p_vlcvideo;
+    delete _p_vlcsubtitle;
     delete _p_vlcplaylist;
     delete _p_vlclog;
     delete _p_vlcinput;
@@ -2782,12 +2607,12 @@ STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
     if( NULL == version )
         return E_POINTER;
 
-    const char *versionStr = VLC_Version();
+    const char *versionStr = libvlc_get_version();
     if( NULL != versionStr )
     {
         *version = BSTRFromCStr(CP_UTF8, versionStr);
 
-        return NULL == *version ? E_OUTOFMEMORY : NOERROR;
+        return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
     }
     *version = NULL;
     return E_FAIL;
@@ -2896,6 +2721,20 @@ STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
     return E_OUTOFMEMORY;
 };
 
+STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcsubtitle;
+    if( NULL != _p_vlcsubtitle )
+    {
+        _p_vlcsubtitle->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
 {
     if( NULL == obj )