[vlc-devel] [PATCH] Change to npapi for giving access to media meta thru new input.meta(i) method.

JM Lambert jeanmichel.lambert7 at gmail.com
Fri Jan 6 10:01:39 CET 2012


---
 npapi/control/npolibvlc.cpp |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/npapi/control/npolibvlc.cpp b/npapi/control/npolibvlc.cpp
index a8a94f6..8ad8fb2 100644
--- a/npapi/control/npolibvlc.cpp
+++ b/npapi/control/npolibvlc.cpp
@@ -31,6 +31,7 @@
 
 #include "position.h"
 
+
 /*
 ** Local helper macros and function
 */
@@ -44,6 +45,8 @@
 #define ERROR_EVENT_NOT_FOUND "ERROR: One or more events could not be found."
 #define ERROR_API_VERSION "ERROR: NPAPI version not high enough. (Gecko >= 1.9 needed)"
 
+
+
 // Make a copy of an NPVariant.
 NPVariant copyNPVariant(const NPVariant& original)
 {
@@ -588,13 +591,13 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
 {
     /* no methods */
-    "none",
+    "meta",
 };
 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
 
 enum LibvlcInputNPObjectMethodIds
 {
-    ID_none,
+    ID_input_meta,
 };
 
 RuntimeNPObject::InvokeResult
@@ -604,10 +607,34 @@ LibvlcInputNPObject::invoke(int index, const NPVariant *args,
     /* is plugin still running */
     if( isPluginRunning() )
     {
+        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+	libvlc_media_t * p_media = libvlc_media_player_get_media(p_md);
+        if( !p_md )
+            RETURN_ON_ERROR;
         switch( index )
         {
-            case ID_none:
-                return INVOKERESULT_NO_SUCH_METHOD;
+            case ID_input_meta:
+		if( argCount == 1)
+                {
+                    char *info;
+                    int i_metaID,  i;
+
+                    /* get subtitles description */
+		     /* check if a number is given by the user
+                     * and get the subtitle number */
+                    if( isNumberValue(args[0]) )
+		    {
+                        i_metaID = numberValue(args[0]);
+			if (i_metaID<0 || i_metaID>libvlc_meta_TrackID)
+                           return INVOKERESULT_INVALID_VALUE;
+
+                        info = libvlc_media_get_meta(p_media,(libvlc_meta_t) i_metaID);
+                    } 
+		    else
+                        return INVOKERESULT_INVALID_VALUE;
+		    return invokeResultString(info, result);
+		}
             default:
                 ;
         }
@@ -1935,3 +1962,4 @@ LibvlcDeinterlaceNPObject::invoke(int index, const NPVariant *args,
     }
     return INVOKERESULT_NO_ERROR;
 }
+
-- 
1.7.5.4




More information about the vlc-devel mailing list