Implement vlc.video.toggleTeletext() JS API method
[vlc.git] / mozilla / control / npolibvlc.cpp
index 2b4e336..7ff456e 100755 (executable)
@@ -2070,11 +2070,13 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =\r
 {\r
     "toggleFullscreen",\r
+    "toggleTeletext"\r
 };\r
 \r
 enum LibvlcVideoNPObjectMethodIds\r
 {\r
     ID_video_togglefullscreen,\r
+    ID_video_toggleteletext\r
 };\r
 \r
 const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *);\r
@@ -2126,6 +2128,34 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar
                     return INVOKERESULT_GENERIC_ERROR;\r
                 }\r
                 return INVOKERESULT_NO_SUCH_METHOD;\r
+            case ID_video_toggleteletext:\r
+                if( argCount == 0 )\r
+                {\r
+                    libvlc_toggle_teletext(p_md, &ex);\r
+                    libvlc_media_instance_release(p_md);\r
+                    if( libvlc_exception_raised(&ex) )\r
+                    {\r
+                        NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+                        libvlc_exception_clear(&ex);\r
+                        return INVOKERESULT_GENERIC_ERROR;\r
+                    }\r
+                    else\r
+                    {\r
+                        VOID_TO_NPVARIANT(result);\r
+                        return INVOKERESULT_NO_ERROR;\r
+                    }\r
+                }\r
+                else\r
+                {\r
+                    /* cannot get md, probably not playing */\r
+                    if( libvlc_exception_raised(&ex) )\r
+                    {\r
+                        NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+                        libvlc_exception_clear(&ex);\r
+                    }\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+                }\r
+                return INVOKERESULT_NO_SUCH_METHOD;\r
             default:\r
                 return INVOKERESULT_NO_SUCH_METHOD;\r
         }\r