Author: toshok
Date: 2007-07-11 23:22:59 -0400 (Wed, 11 Jul 2007)
New Revision: 81843

Modified:
   trunk/moon/plugin/ChangeLog
   trunk/moon/plugin/plugin-class.cpp
   trunk/moon/plugin/plugin-class.h
Log:
        * plugin-class.cpp, plugin-class.h: wrap the MediaElement enough
        to provide the start/stop/pause methods.

2007-07-11  Chris Toshok  <[EMAIL PROTECTED]>



Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-07-12 03:15:14 UTC (rev 81842)
+++ trunk/moon/plugin/ChangeLog 2007-07-12 03:22:59 UTC (rev 81843)
@@ -1,5 +1,10 @@
 2007-07-11  Chris Toshok  <[EMAIL PROTECTED]>
 
+       * plugin-class.cpp, plugin-class.h: wrap the MediaElement enough
+       to provide the start/stop/pause methods.
+
+2007-07-11  Chris Toshok  <[EMAIL PROTECTED]>
+
        * plugin-class.cpp, plugin-class.h, plugin-glue.cpp, plugin.h,
        plugin.cpp: I know this looks like a scary change, but 90% of the
        code is the same.  I just took advantage of the fact that we

Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp  2007-07-12 03:15:14 UTC (rev 81842)
+++ trunk/moon/plugin/plugin-class.cpp  2007-07-12 03:22:59 UTC (rev 81843)
@@ -854,13 +854,23 @@
 MoonlightDependencyObjectObject*
 DependencyObjectCreateWrapper (NPP instance, DependencyObject *obj)
 {
-       NPClass *np_class = MoonlightDependencyObjectClass;
+       NPClass *np_class;
 
        /* for DependencyObject subclasses which have special plugin classes, 
check here */
        if (Type::Find (obj->GetObjectType ())->IsSubclassOf (Type::COLLECTION))
                np_class = MoonlightCollectionClass;
-       else if (obj->GetObjectType() == Type::STORYBOARD)
-               np_class = MoonlightStoryboardClass;
+       else {
+               switch (obj->GetObjectType()) {
+               case Type::STORYBOARD:
+                       np_class = MoonlightStoryboardClass;
+                       break;
+               case Type::MEDIAELEMENT:
+                       np_class = MoonlightMediaElementClass;
+                       break;
+               default:
+                       np_class = MoonlightDependencyObjectClass;
+               }
+       }
 
        MoonlightDependencyObjectObject *depobj
                = (MoonlightDependencyObjectObject*)NPN_CreateObject (instance,
@@ -1107,7 +1117,77 @@
 
 MoonlightStoryboardType* MoonlightStoryboardClass;
 
+/*** MoonlightMediaElementClass 
***************************************************/
 
+static const char *const
+moonlight_media_element_methods [] = {
+       "stop",
+       "play",
+       "pause"
+};
+
+
+static bool
+moonlight_media_element_has_method (NPObject *npobj, NPIdentifier name)
+{
+       if (HAS_METHOD (moonlight_media_element_methods, name))
+               return true;
+
+       return MoonlightDependencyObjectClass->hasMethod (npobj, name);
+}
+
+static bool
+moonlight_media_element_invoke (NPObject *npobj, NPIdentifier name,
+                               const NPVariant *args, uint32_t argCount,
+                               NPVariant *result)
+{
+       MediaElement *media = 
(MediaElement*)((MoonlightDependencyObjectObject*)npobj)->dob;
+
+       if (name_matches (name, "play")) {
+               if (argCount != 0)
+                       return true;
+
+               media->Play ();
+
+               VOID_TO_NPVARIANT (*result);
+
+               return true;
+       }
+       else if (name_matches (name, "pause")) {
+               if (argCount != 0)
+                       return true;
+
+               media->Pause ();
+
+               VOID_TO_NPVARIANT (*result);
+
+               return true;
+       }
+       else if (name_matches (name, "stop")) {
+               if (argCount != 0)
+                       return true;
+
+               media->Stop ();
+
+               VOID_TO_NPVARIANT (*result);
+
+               return true;
+       }
+       else 
+               return MoonlightDependencyObjectClass->invoke (npobj, name,
+                                                              args, argCount,
+                                                              result);
+}
+
+MoonlightMediaElementType::MoonlightMediaElementType ()
+{
+       hasMethod = moonlight_media_element_has_method;
+       invoke = moonlight_media_element_invoke;
+}
+
+MoonlightMediaElementType* MoonlightMediaElementClass;
+
+
 void
 plugin_init_classes ()
 {
@@ -1119,5 +1199,6 @@
        MoonlightDependencyObjectClass = new MoonlightDependencyObjectType ();
        MoonlightCollectionClass = new MoonlightCollectionType ();
        MoonlightStoryboardClass = new MoonlightStoryboardType ();
+       MoonlightMediaElementClass = new MoonlightMediaElementType ();
 }
 

Modified: trunk/moon/plugin/plugin-class.h
===================================================================
--- trunk/moon/plugin/plugin-class.h    2007-07-12 03:15:14 UTC (rev 81842)
+++ trunk/moon/plugin/plugin-class.h    2007-07-12 03:22:59 UTC (rev 81843)
@@ -115,7 +115,7 @@
 };
 extern MoonlightCollectionType* MoonlightCollectionClass;
 
-/*** MoonlightCollectionClass 
***************************************************/
+/*** MoonlightStoryboardClass 
***************************************************/
 
 struct MoonlightStoryboardType : MoonlightDependencyObjectType {
   MoonlightStoryboardType ();
@@ -123,4 +123,13 @@
 
 extern MoonlightStoryboardType* MoonlightStoryboardClass;
 
+/*** MoonlightMediaElement ***************************************************/
+
+struct MoonlightMediaElementType : MoonlightDependencyObjectType {
+  MoonlightMediaElementType ();
+};
+
+extern MoonlightMediaElementType* MoonlightMediaElementClass;
+
+
 #endif /* PLUGIN_CLASS */

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to