[vlc-commits] activex/npapi: fix vlc.video.subtitle index

Daniel Amm git at videolan.org
Fri May 22 10:21:21 CEST 2015


npapi-vlc | branch: master | Daniel Amm <da2424 at t-online.de> | Thu May 21 20:24:19 2015 +0200| [4651c8bd75eb12b35dfb11f8a89c5c3783d20b2b] | committer: Jean-Baptiste Kempf

activex/npapi: fix vlc.video.subtitle index

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=4651c8bd75eb12b35dfb11f8a89c5c3783d20b2b
---

 activex/vlccontrol2.cpp       |    7 +++++--
 npapi/npruntime/npolibvlc.cpp |   10 +++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/activex/vlccontrol2.cpp b/activex/vlccontrol2.cpp
index 14da696..84a4601 100644
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -981,13 +981,16 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
     if( NULL == spu )
         return E_POINTER;
 
-    *spu = _plug->get_player().get_mp().spu();
+    *spu = _plug->get_player().currentSubtitleTrack();
     return S_OK;
 }
 
 STDMETHODIMP VLCVideo::put_subtitle(long spu)
 {
-    _plug->get_player().get_mp().setSpu( spu );
+    auto tracks = _plug->get_player().get_mp().spuDescription();
+    if ( spu >= tracks.size() )
+        return E_INVALIDARG;
+    _plug->get_player().get_mp().setSpu( tracks[spu].id() );
     return S_OK;
 }
 
diff --git a/npapi/npruntime/npolibvlc.cpp b/npapi/npruntime/npolibvlc.cpp
index 5329e8c..246fac3 100644
--- a/npapi/npruntime/npolibvlc.cpp
+++ b/npapi/npruntime/npolibvlc.cpp
@@ -1172,15 +1172,12 @@ LibvlcSubtitleNPObject::getProperty(int index, npapi::OutVariant& result)
         {
             case ID_subtitle_track:
             {
-                /* get the current internal subtitles track ID */
                 result = p_plugin->player().currentSubtitleTrack();
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_subtitle_count:
             {
-                /* get the number of subtitles available */
                 result = mp.spuCount();
-                /* return it */
                 return INVOKERESULT_NO_ERROR;
             }
         }
@@ -1353,7 +1350,7 @@ LibvlcVideoNPObject::getProperty(int index, npapi::OutVariant& result)
             }
             case ID_video_subtitle:
             {
-                result = mp.spu();
+                result = p_plugin->player().currentSubtitleTrack();
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_crop:
@@ -1436,7 +1433,10 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
             {
                 if( v.is<int>() )
                 {
-                    mp.setSpu( v );
+                    auto tracks = mp.spuDescription();
+                    if ( v >= tracks.size() )
+                        return INVOKERESULT_INVALID_ARGS;
+                    mp.setSpu( tracks[ v ].id() );
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_INVALID_VALUE;



More information about the vlc-commits mailing list