linterna-magica-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linterna-magica-commit] [322] Experimental fix for bugs #36888.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [322] Experimental fix for bugs #36888.
Date: Fri, 26 Oct 2012 10:55:16 +0000

Revision: 322
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=322
Author:   valkov
Date:     2012-10-26 10:55:16 +0000 (Fri, 26 Oct 2012)
Log Message:
-----------
Experimental fix for bugs #36888. See also r303.

In addition to the type switching that prevents the loading of a flash
plugin in the background, it is needed to remove the swf extension of
the file in the src/data attribute. Some flash plugins detect objects
only by source extension.

#future_release_0.0.13

Revision Links:
--------------
    http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=303

Ticket Links:
------------
    http://savannah.gnu.org/bugs/?36888

Modified Paths:
--------------
    trunk/src/lm_video_and_flash_objects_helper_functions.js

Modified: trunk/src/lm_video_and_flash_objects_helper_functions.js
===================================================================
--- trunk/src/lm_video_and_flash_objects_helper_functions.js    2012-10-06 
18:02:23 UTC (rev 321)
+++ trunk/src/lm_video_and_flash_objects_helper_functions.js    2012-10-26 
10:55:16 UTC (rev 322)
@@ -196,9 +196,8 @@
 
 
     // See https://savannah.nongnu.org/bugs/?36888
-    flash_object = 
-       this.force_flash_video_object_type(flash_object,
-                                    "application/x-shockwave-flash");
+    flash_object = this.force_flash_video_object_start(flash_object);
+
     flash_object.style.removeProperty("display");
 
     return flash_object;
@@ -219,48 +218,128 @@
     // Force the playback to stop. Setting the object on the
     // background and changing its type alone does not work. 
     // See https://savannah.nongnu.org/bugs/?36888
-    flash_object = this.force_flash_video_object_type(flash_object,
-                                               "x-fake/x-flash-stopped");
+    flash_object = this.force_flash_video_object_stop(flash_object);
 
     flash_object.style.setProperty("display", "none", "important");
 
     return flash_object;
 }
 
-// Force the flash object to another type. Used when hiding the flash
-// player to stop its playback so there is no dual playback as
-// described in bug #36888.
+LinternaMagica.prototype.force_flash_video_object_stop =
+function(flash_object)
+{
+    var clone = this.force_flash_video_object_src(flash_object, 
+                                                    "x-fake-flash");
+    clone = 
+       this.force_flash_video_object_type(clone,
+                                      "x-fake/x-flash-stopped");
+
+    clone = this.force_flash_video_object_injection(flash_object, clone);
+
+    return clone;
+}
+
+LinternaMagica.prototype.force_flash_video_object_start =
+function(flash_object)
+{
+    var clone = this.force_flash_video_object_src(flash_object, "swf");
+
+    clone = 
+       this.force_flash_video_object_type(clone,
+                                      "application/x-shockwave-flash");
+
+    clone = this.force_flash_video_object_injection(flash_object, clone);
+
+    return clone;
+}
+
+// Add/remove swf from the flash object src/data attribute. Used when
+// hiding the flash player to stop its playback so there is no dual
+// playback as described in bug #36888.
 // See https://savannah.nongnu.org/bugs/?36888
-LinternaMagica.prototype.force_flash_video_object_type =
-function(flash_object, type)
+LinternaMagica.prototype.force_flash_video_object_src =
+function(flash_object, src)
 {
-    if (!flash_object || !type)
+    if (!flash_object || !src)
     {
        return null;
     }
 
+    var old_src = null;
+
+    if (/swf/i.test(src))
+    {
+       old_src = "x-fake-flash";
+    }
+    else if (/x-fake-flash/i.test(src))
+    {
+       old_src = "swf";
+    }
+    else
+    {
+       return flash_object;
+    }
+
+    var src_attribute = 
+       /object/i.test(flash_object.localName) ? "data" : "src";
+
+    var full_src = flash_object.getAttribute(src_attribute);
+
+    if (!full_src)
+    {
+       return flash_object;
+    }
+
+    full_src = full_src.replace('.'+old_src, '.'+src);
+
+    var clone = flash_object.cloneNode(true);
+    clone.linterna_magica_id = flash_object.linterna_magica_id;
+    
+    clone.setAttribute(src_attribute, full_src);
+
+    return clone;
+}
+
+LinternaMagica.prototype.force_flash_video_object_injection =
+function(flash_object, clone)
+{
     var sibling = flash_object.nextSibling ? 
        flash_object.nextSibling : null;
 
     var parent = flash_object.parentNode;
 
-    var clone = flash_object.cloneNode(true);
-    clone.linterna_magica_id = flash_object.linterna_magica_id;
-    
     flash_object.parentNode.removeChild(flash_object);
-
-    flash_object = clone;
-    flash_object.setAttribute("type", type);
-    
+ 
     if (sibling)
     {
-       parent.insertBefore(flash_object, sibling);
+       parent.insertBefore(clone, sibling);
     }
     else
     {
-       parent.appendChild(flash_object);
+       parent.appendChild(clone);
     }
 
+    return clone;
+}
+
+// Force the flash object to another type. Used when hiding the flash
+// player to stop its playback so there is no dual playback as
+// described in bug #36888.
+// See https://savannah.nongnu.org/bugs/?36888
+LinternaMagica.prototype.force_flash_video_object_type =
+function(flash_object, type)
+{
+    if (!flash_object || !type)
+    {
+       return null;
+    }
+  
+    var clone = flash_object.cloneNode(true);
+    clone.linterna_magica_id = flash_object.linterna_magica_id;
+    
+    flash_object = clone;
+    flash_object.setAttribute("type", type);
+   
     return flash_object;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]