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

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

[linterna-magica-commit] [171] Changes for tasks #11064.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [171] Changes for tasks #11064.
Date: Mon, 01 Aug 2011 17:57:19 +0000

Revision: 171
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=171
Author:   valkov
Date:     2011-08-01 17:57:18 +0000 (Mon, 01 Aug 2011)
Log Message:
-----------
Changes for tasks #11064. CSS and code fixes for YoTube, Dailymotion and Vimeo, 
required for the HTML5 switch.

Ticket Links:
------------
    http://savannah.gnu.org/task/?11064

Modified Paths:
--------------
    trunk/HELP
    trunk/HELP.bg
    trunk/src/lm_config_options.js
    trunk/src/lm_create_video_object.js
    trunk/src/lm_init_options.js
    trunk/src/lm_interface_toggle_plugin.js
    trunk/src/lm_site_dailymotion.js
    trunk/src/lm_site_vimeo.js
    trunk/src/lm_site_youtube.js
    trunk/src/lm_video_and_flash_objects_helper_functions.js
    trunk/utilities/linternamagica_user_config.user.js

Modified: trunk/HELP
===================================================================
--- trunk/HELP  2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/HELP  2011-08-01 17:57:18 UTC (rev 171)
@@ -11,7 +11,7 @@
     "debug": 1,
     "log_to": "web",
     "updates": "1w",
-    "priority": "self",
+    "priority": "html5, self, plugin",
     "autostart": "off",
     "controls": "self",
     "locale": "auto",
@@ -58,13 +58,17 @@
                d = day, w = week, m = month, y = year
        off/disabled/no/never/false/0: Do not check
   priority
-      This options sets if Linterna Mágica should replace found
-      objects.
+      This options determines how opbject found by Linterna Mágica
+      should be played. You can set multiple values separated with
+      ",", without the quotes. The default value is "html5, self, plugin".
         self
-            Replace the flash object (default)
+            Replace the flash objects
         plugin
             Use Gnash/Swfdec. A button next to the flash object
             switches to Linterna Mágica.
+       html5
+           Use HTML5 player if the site provides one. A button next
+           to the player switches to Linterna Mágica.
   autostart
       Auto start playback. If more than one object is found, only the
       first one will start playback.

Modified: trunk/HELP.bg
===================================================================
--- trunk/HELP.bg       2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/HELP.bg       2011-08-01 17:57:18 UTC (rev 171)
@@ -10,7 +10,7 @@
     "debug": 1,
     "log_to": "web",
     "updates": "1w",
-    "priority": "self",
+    "priority": "html5, self, plugin",
     "autostart": "off",
     "controls": "self",
     "locale": "auto",
@@ -58,14 +58,19 @@
        off/disabled/no/never/false/0
            Без проверка
   priority
-      Тази настройка указва дали Linterna Mágica ще заменя откритите
-      обекти.
+      Тази настройка определя как да се възпрозивеждат обектите
+      открити от Linterna Mágica. Може да зададете няколко стойности
+      разделени с „,“ (без кавичките).  Стандартната стойност е „html5,
+      self, plugin“.
         self
-            Замяна на флаш обектите (стандартно)
+            Замяна на флаш обектите
         plugin
             Ще се използва Gnash/Swfdec. Бутон след флаш обекта
             включва Linterna Mágica.
-
+       html5
+           Клиповете ще се възпрозивеждат чрез HTML5, ако страницата
+            има такава възможност. Бутон след HTML5 елемента включва
+            Linterna Mágica.
   autostart
       Автоматично изпълнение. Ако обектите са няколко, само в първия
       ще започне изпълнение.

Modified: trunk/src/lm_config_options.js
===================================================================
--- trunk/src/lm_config_options.js      2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/src/lm_config_options.js      2011-08-01 17:57:18 UTC (rev 171)
@@ -47,22 +47,69 @@
 // set this.priority  according to configuration
 LinternaMagica.prototype.set_priority = function(priority)
 {
-    // self || plugin
-    var set_priority_to = priority ? priority :"";
+    var std_priority = new Object();
 
+    std_priority.html5 = 13;
+    std_priority.self = 12;
+    std_priority.plugin = 11;
+    std_priority.options = 3;
+
     // If not valid value force to self
     if (!priority ||
-       (!/plugin/i.test(priority) &&
-        !/self/i.test(priority)))
+       typeof(priority) !== "string")
     {
-       set_priority_to = "self";
+       priority = "html5,self,plugin";
     }
 
-    // If no plugin installed force to self
+    // Clear whitespace
+    priority = priority.replace(/\s*/g,"");
+
+    // Array [html5, self, plugin]
+    var set_priority_to = priority.split(/,/) ;
+
+    var t = new Object();
+    t.options = 0;
+
+    for (var i=0, l=set_priority_to.length; i< l; i++)
+    {
+       var o = set_priority_to[i];
+
+       // Check for valid option and use only them
+       if (/plugin/i.test(o) || /self/i.test(o) || /html5/i.test(o))
+       {
+           // The first element has higher priority and the last one
+           // has lowest. Mimic std_priority values (13, 12, 11)
+           t[o] = (l+10) - i;
+           t.options ++;
+       }
+    }
+
+    if (!t.options)
+    {
+       set_priority_to = std_priority;
+    }
+    else
+    {
+       // Set the extracted values. In cases where only few options
+       // are set by the user, values for the missing options are
+       // calculated as "std_priority.val - 10". This way they will
+       // not have the standard priority and will not have higher
+       // priority then the user defined.
+       set_priority_to = new Object();
+       set_priority_to.html5  = t.html5 ? t.html5 : (std_priority.html5 -10);
+       set_priority_to.self  = t.self ? t.self : (std_priority.self - 10);
+       set_priority_to.plugin  = t.plugin ? t.plugin : (std_priority.plugin - 
10);
+       set_priority_to.options = 3;
+    }
+
     if (!this.plugin_is_installed &&
-       /plugin/i.test(priority))
+       (set_priority_to.plugin > set_priority_to.self))
     {
-       set_priority_to="self";
+       // Switch the values/places of self and plugin, if no plugin
+       // installed and plugin has higher priority then self.
+       t = set_priority_to.self;
+       set_priority_to.self = set_priority_to.plugin;
+       set_priority_to.plugin = t;
     }
 
     this.priority = set_priority_to;

Modified: trunk/src/lm_create_video_object.js
===================================================================
--- trunk/src/lm_create_video_object.js 2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/src/lm_create_video_object.js 2011-08-01 17:57:18 UTC (rev 171)
@@ -106,11 +106,20 @@
                                     self.about.apply(self, [ev, el]);
                                 }, false);
 
+    var site_html5_player =
+       this.find_site_html5_player_wrapper(object_data.parent);
+
+    var toggle_plugin_switch_type = 
+       site_html5_player ? "html5" : "plugin";
+
     // If the plugin is not installed this is useless
-    if (this.plugin_is_installed)
+    if (this.plugin_is_installed || site_html5_player)
     {
        // append before download link (first button in the header)
-       var toggle_plugin = this.create_toggle_plugin_link(null,id);
+       var toggle_plugin = 
+           this.create_toggle_plugin_link(null,id,
+                                          toggle_plugin_switch_type);
+
        header.appendChild(toggle_plugin);
     }
 
@@ -313,12 +322,23 @@
     // Add link after the object/embed
     // this.set_priority() has set this.priority
     // to self if there is no plugin
-    if (this.plugin_is_installed)
+       if (this.plugin_is_installed || site_html5_player)
     {
-       toggle_plugin = this.create_toggle_plugin_link(this.priority, id);
+       toggle_plugin =
+           this.create_toggle_plugin_link("link-not-in-header", id,
+                                         toggle_plugin_switch_type);
 
-       var before = this.get_flash_video_object(id).nextSibling;
+       var before = null;
 
+       if (this.plugin_is_installed && !site_html5_player)
+       {
+           before = this.get_flash_video_object(id).nextSibling;
+       }
+       else if (site_html5_player)
+       {
+           before = site_html5_player.nextSibling;
+       }
+
        if (before)
        {
            object_data.parent.insertBefore(toggle_plugin, before);
@@ -327,8 +347,14 @@
        {
            object_data.parent.appendChild(toggle_plugin);
        }
-       if (!/plugin/i.test(this.priority))
+
+       if (((this.priority.self > this.priority.plugin) && 
+            this.plugin_is_installed && !site_html5_player) ||
+           ((this.priority.self > this.priority.html5) &&
+            site_html5_player))
        {
+           // Hide the toggle plugin button only if self has higher
+           // priority then plugin and html5.
            toggle_plugin.style.setProperty("display", "none",
                                            "important");
        }
@@ -340,13 +366,18 @@
        container.appendChild(controls);
     }
 
-    // IMPORTANT: First remove the object
-    // then insert the new one, otherwise a loop is created
-    // in extract_objects_from_dom.
+    var dom_object =  this.get_flash_video_object(id);
 
-    var dom_object =  this.get_flash_video_object(id);
+    if (!dom_object)
+    {
+       dom_object = site_html5_player;
+    }
+
     // Remove/hide the object if it is in DOM
-    if (/self/i.test(this.priority) &&
+    if ((((this.priority.self > this.priority.plugin) &&
+         !site_html5_player) || 
+        ((this.priority.self > this.priority.html5) &&
+         site_html5_player)) &&
        dom_object &&
        // The object is still in DOM some scripts remove it
        dom_object.parentNode)
@@ -356,14 +387,21 @@
            object_data.use_sibling = dom_object.nextSibling;
        }
 
-       this.hide_flash_video_object(id,dom_object.parentNode);
+       if (!site_html5_player)
+       {
+           this.hide_flash_video_object(id,dom_object.parentNode);
+       }
+       else 
+       {
+           this.hide_site_html5_player(object_data.parent);
+       }
     }
 
-    if (/self/i.test(this.priority) && this.plugin_is_installed)
+    if (toggle_plugin)
     {
        object_data.parent.insertBefore(container, toggle_plugin);
     }
-    else if(/self/i.test(this.priority))
+    else
     {
        if (object_data.use_sibling)
        {
@@ -380,6 +418,14 @@
        }
     }
 
+    if (((this.priority.self < this.priority.plugin) && 
+        this.plugin_is_installed) || 
+       ((this.priority.self < this.priority.html5) && 
+        site_html5_player))
+    {
+       this.hide_lm_video(object_data.linterna_magica_id);
+    }
+
     // Defaults style fixes applied always.
     about_box.style.setProperty("overflow", "auto", "important");
 
@@ -473,7 +519,7 @@
     // Init the web controls functions
     // only if Linterna Mágica has priority
     if (this.controls &&
-       /self/i.test(this.priority))
+       (this.priority.self > this.priority.plugin))
     {
        this.player.init.apply(this,[id]);
     }

Modified: trunk/src/lm_init_options.js
===================================================================
--- trunk/src/lm_init_options.js        2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/src/lm_init_options.js        2011-08-01 17:57:18 UTC (rev 171)
@@ -49,10 +49,16 @@
        // configured.
        // off/disabled/no/never/false/0: Do not check
        "updates": "1w",
-       // Set which program has priority to play the video
-       // self: Replace the swf object
+       // This options determines how opbject found by Linterna Mágica
+       // should be played. You can set multiple values separated with
+       // ",", without the quotes. Default value is "html5, self,
+       // plugin".
+        // self: Replace the flash object
        // plugin: Add link after the swf object that replaces it
-       "priority": "self",
+       // html5: Add link after the HTMl5 player (if a site provides
+       // one) that replaces it
+       // Default value "html5, self, plugin"
+       "priority": "html5, self, plugin",
        // Automatically start the video playback
        // enabled: Auto start the clip (default)
        // disabled:  Do not start the clip

Modified: trunk/src/lm_interface_toggle_plugin.js
===================================================================
--- trunk/src/lm_interface_toggle_plugin.js     2011-07-30 09:34:04 UTC (rev 
170)
+++ trunk/src/lm_interface_toggle_plugin.js     2011-08-01 17:57:18 UTC (rev 
171)
@@ -27,15 +27,18 @@
 
 // END OF LICENSE HEADER
 
-// Create the link/button to switch between flash plugin and
-// Linterna Mágica
-LinternaMagica.prototype.create_toggle_plugin_link = 
function(plugin_priority,id)
+// Create the link/button to switch between flash plugin or HTML5
+// player and Linterna Mágica
+LinternaMagica.prototype.create_toggle_plugin_link =
+function(not_in_header,id,switch_type)
 {
     var toggle_plugin = document.createElement("a");
     var self = this;
     var wrapper = null;
+
     toggle_plugin.setAttribute("href", "#");
-    if (plugin_priority)
+
+    if (not_in_header)
     {
        toggle_plugin.setAttribute("class", "linterna-magica-toggle-plugin");
     }
@@ -49,7 +52,7 @@
     toggle_plugin.addEventListener("click",
                                   toggle_plugin_click_function, false);
 
-    if (plugin_priority)
+    if (not_in_header)
     {
 
        toggle_plugin.textContent = "Linterna Mágica >>";
@@ -62,22 +65,39 @@
     }
     else
     {
-       toggle_plugin.textContent = this._("Plugin");
+       if (/html5/i.test(switch_type))
+       {
+           toggle_plugin.textContent = this._("HTML5");
+       }
+       else
+       {
+           toggle_plugin.textContent = this._("Plugin");
+       }
+
        toggle_plugin.setAttribute("class", 
                                   "linterna-magica-toggle-plugin-header");
        toggle_plugin.setAttribute("id", 
                                   "linterna-magica-toggle-plugin-header-"+id);
     }
 
-    toggle_plugin.setAttribute("title",
-                              this._("Switch between flash plugin"+
-                                " and Linterna Mágica"));
+    if (/html5/i.test(switch_type))
+    {
+       toggle_plugin.setAttribute("title",
+                                  this._("Switch between site's HTML5 "+
+                                         "player and Linterna Mágica"));
+    }
+    else
+    {
+       toggle_plugin.setAttribute("title",
+                                  this._("Switch between flash plugin"+
+                                         " and Linterna Mágica"));
+    }
 
     return wrapper ? wrapper : toggle_plugin;
 }
 
-// Event listener function that switches between flash plugin and
-// Linterna Mágica
+// Event listener function that switches between flash plugin or HTML5
+// player and Linterna Mágica
 LinternaMagica.prototype.toggle_plugin = function(event,element)
 {
     event.preventDefault();
@@ -95,20 +115,33 @@
        document.getElementById("linterna-magica-video-object-"+
                                linterna_magica_id);
 
-    var flash_object = 
+    if (!video_object)
+    {
+       return null;
+    }
+
+    var html5_parent = null;
+
+    var site_player = 
        this.get_flash_video_object(linterna_magica_id,
                                    // The parent of the div holding
                                    // Linterna Mágica
                                    video_object.parentNode.parentNode);
+    if (!site_player)
+    {
+       html5_parent = video_object.parentNode.parentNode;
+       site_player = 
+           this.find_site_html5_player_wrapper(html5_parent);
 
-    if (!flash_object && !video_object)
-    {
-       return null;
+       if (!site_player)
+       {
+           return null;
+       }
     }
 
     // Visible flash, hidden video object. Display has value (none)
     // when the object is hidden.
-    if (!flash_object.style.getPropertyValue("display") &&
+    if (!site_player.style.getPropertyValue("display") &&
        video_object.parentNode.style.getPropertyValue("display"))
     {
        this.log("LinternaMagica.toggle_plugin:\n"+
@@ -116,8 +149,16 @@
                 linterna_magica_id+
                 ") with video object.", 4);
 
-       this.hide_flash_video_object(linterna_magica_id, 
-                                    flash_object.parentNode);
+       if (!html5_parent)
+       {
+           this.hide_flash_video_object(linterna_magica_id, 
+                                        site_player.parentNode);
+       }
+       else
+       {
+           this.pause_site_html5_player(html5_parent);
+           this.hide_site_html5_player(html5_parent);
+       }
 
        this.show_lm_video(linterna_magica_id);
 
@@ -134,20 +175,28 @@
     // Hidden flash, visible video object. Display has value (none)
     // when the object is hidden.
     else if (!video_object.parentNode.style.getPropertyValue("display") &&
-            flash_object.style.getPropertyValue("display"))
+            site_player.style.getPropertyValue("display"))
     {
        this.log("LinternaMagica.toggle_plugin:\n"+
                 "Replacing/hiding video object (id:"+
                 linterna_magica_id+
                 ") with swf object.", 4);
 
+       if (!html5_parent)
+       {
+           this.show_flash_video_object(linterna_magica_id, 
+                                        site_player.parentNode);
+
+       }
+       else
+       {
+           this.show_site_html5_player(html5_parent);
+       }
+
        this.hide_lm_video(linterna_magica_id);
-       this.show_flash_video_object(linterna_magica_id, 
-                                    flash_object.parentNode);
        
        // External toggle plugin link
        var ext_toggle_wrapper = video_object.parentNode.nextSibling;
        ext_toggle_wrapper.style.removeProperty("display");
-
     }
 }

Modified: trunk/src/lm_site_dailymotion.js
===================================================================
--- trunk/src/lm_site_dailymotion.js    2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/src/lm_site_dailymotion.js    2011-08-01 17:57:18 UTC (rev 171)
@@ -30,6 +30,14 @@
 // Extract data for dailymotion video links
 LinternaMagica.prototype.extract_dailymotion_links = function(data)
 {
+    // Dailymotion links could be extracted via JSON call at
+    // http://www.dailymotion.com/json/video/<video_id>. To get the
+    // links one must use set a "fields" field for example to
+    // "stream_ogg_url,stream_h264_sd_url,stream_h264_hq_url".  When
+    // set and used with callback field the server returns an error
+    // 500. Without the callabck function the results from JSON
+    // requests are useless.
+
     var links_re = new RegExp (
        "sdurl"+
            "(\\\"|\\\')*\\\s*(\\\=|\\\:|\\\,)\\\s*(\\\"|\\\')*"+
@@ -77,10 +85,46 @@
 LinternaMagica.prototype.sites["dailymotion.com"].no_flash_plugin_installed =
 function()
 {
-    this.request_video_link({video_id: window.location.pathname});
+    var data = new Object();
+    data.video_id = window.location.pathname;
+
+    if (this.wait_xhr)
+    {
+       this.log("LinternaMagica.extract_objects_from_dom:\n"+
+                "Waiting "+this.wait_xhr+
+                " ms ("+(this.wait_xhr/1000)+
+                " s) before requesting video link via"+
+                " video_id "+data.video_id+" ",1);
+
+       var self = this;
+       setTimeout(function() {
+           self.request_video_link.apply(self,[data]);
+       }, this.wait_xhr);
+    }
+    else
+    {
+       this.request_video_link(data);
+    }
+
     return true;
 }
 
+LinternaMagica.prototype.sites["dailymotion.com"].flash_plugin_installed =
+function()
+{
+    var site_html5_player = this.find_site_html5_player_wrapper(document);
+
+    // If there is html5 player and flash plugin is installed no SWF
+    // object will be created. We must examine scripts.
+    if (site_html5_player)
+    {
+       return this.sites["dailymotion.com"].
+           no_flash_plugin_installed.apply(this, [arguments]);
+    }
+
+    return true;
+}
+
 LinternaMagica.prototype.sites["dailymotion.com"].process_cookies =
 function()
 {
@@ -135,6 +179,16 @@
     this.extract_cookies();
     this.expire_cookies();
 
+    // For some strange reason the cookie that activates the HTML5
+    // player could not be expired. It must be forced to non-relevant
+    // for the site value. If it is present, the XHR does not get a
+    // flash player version of the page and no data could be
+    // extracted.
+    if (/html5_switch=1/i.test(document.cookie))
+    {
+       document.cookie = "html5_switch=0;";
+    }
+
     return result;
 }
 
@@ -143,9 +197,10 @@
 {
     var client = args.client;
     var object_data = args.object_data;
-
-    if (!this.plugin_is_installed &&
-       !object_data.linterna_magica_id && 
+    
+    // !this.plugin_is_installed is removed so it could work when
+    //  plugin is installed and HTML5 is active.
+    if (!object_data.linterna_magica_id && 
        !object_data.parent)
     {
        // In Dailymotion the script that creates the flash
@@ -181,6 +236,11 @@
 
        body.innerHTML = original_body_data;
 
+       if (!object_data)
+       {
+           return null;
+       }
+
        object_data.parent = 
            this.get_first_element_by_class("dmpi_video_playerv[0-9]+");
 
@@ -200,5 +260,94 @@
        this.restore_cookies();
     }
 
+    // For some strange reason the cookie that activates the HTML5
+    // player could not be expired. It was forced to non-relevant for
+    // the site value. If it is present, the XHR does not get a flash
+    // player version of the page and no data could be extracted.  It
+    // must be restored.
+    if (/html5_switch=0/i.test(document.cookie))
+    {
+       document.cookie = "html5_switch=1;";
+    }
+
+
     return object_data;
 }
+
+LinternaMagica.prototype.sites["dailymotion.com"].insert_object_after_xhr =
+function(object_data)
+{
+    // Skip the remove_plugin_install_waring in the default object
+    // creation code after XHR. This keeps the HTML5 error screen.
+    if (/html5_switch=1/i.test(document.cookie))
+    {
+       this.log("LinternaMagica.request_video_link_parse response:\n"+
+                "Creating video object with url: "+object_data.link,1);
+       this.create_video_object(object_data)
+       return false;
+    }
+
+    // Just exit and leave object insertion to the XHR function.
+    return true;
+}
+
+LinternaMagica.prototype.sites["dailymotion.com"].css_fixes =
+function(object_data)
+{
+    var parent = object_data.parent;
+    parent.style.setProperty("margin-bottom", "30px", "important");
+
+    var html5_error = 
+       this.get_first_element_by_class("error_screen");
+
+    if (html5_error)
+    {
+       var lm = document.getElementById("linterna-magica-"+
+                                        object_data.linterna_magica_id);
+       // Hide the error screen when the LM wrapper is visible
+       if (lm && !lm.style.display)
+       {
+           html5_error.style.setProperty("display", "none", "important");
+       }
+
+       // Hide / show on toggle_plugin clicks 
+       var toggle_header =
+           document.getElementById("linterna-magica-toggle-plugin-header-"+
+                                   object_data.linterna_magica_id);
+       var toggle_after =
+           document.getElementById("linterna-magica-toggle-plugin-"+
+                                   object_data.linterna_magica_id);
+
+       var header_fn = function(ev)
+       {
+           var err_screen  = document.querySelector(".error_screen");
+
+           if (!err_screen)
+           {
+               return;
+           }
+
+           if (err_screen.style.display)
+           {
+               err_screen.style.removeProperty("display");
+           }
+           else
+           {
+               err_screen.style.setProperty("display", 
+                                            "none", "important");
+           }
+       };
+
+       if (toggle_header)
+       {
+           toggle_header.addEventListener("click",header_fn,false);
+       }
+
+       if (toggle_after)
+       {
+           toggle_after.addEventListener("click",header_fn,false);
+       }
+    }
+
+    return null;
+}

Modified: trunk/src/lm_site_vimeo.js
===================================================================
--- trunk/src/lm_site_vimeo.js  2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/src/lm_site_vimeo.js  2011-08-01 17:57:18 UTC (rev 171)
@@ -54,8 +54,6 @@
        // Will be cleared in if (detected)
        // clearInterval(this.vimeo_browser_upgrade_timeout);
        detected=1;
-       // Remove the HTML5 player in Epiphany/Midory
-       object_data.parent.removeChild(object_data.parent.lastChild);
     }
 
     var scripts = object_data.parent.getElementsByTagName("script");
@@ -86,6 +84,10 @@
     }
 }
 
+// Reference YT's function. Checks for HTML5 player and if found, scan
+// scripts.
+LinternaMagica.prototype.sites["vimeo.com"].flash_plugin_installed = 
"youtube.com";
+
 // Extract object data in Vimeo. This makes Firefox and forks to work
 // without plugin and without HTML5 (missing H264)
 LinternaMagica.prototype.sites["vimeo.com"].extract_object_from_script = 
function()
@@ -255,14 +257,28 @@
 {
     // The thumbnail image overlaps the toggle plugin button after our
     // changes. This way our button is visible.
-    if (object_data.parent.firstChild)
+    if (object_data.parent.firstChild &&
+       /HTMLDiv/i.test(object_data.parent.firstChild))
     {
        // The first child should be a div with thumbnail as
        // background. Reduce it's size so it will not overlap our
-       // button.
-       object_data.parent.firstChild.style.
-           setProperty("height", parseInt(object_data.height)+"px",
-                       "important");
+       // button. A size of 0 px does not hide the linterna magica
+       // header object, but moves the flash object down.  A size of
+       // object_data.height px does not hide the header, but does
+       // not move the flash object. The only option left is to
+       // remove the element. This fixes the toggle_plugin
+       // displacement, if the height of the element is changed.
+       object_data.parent.removeChild(object_data.parent.firstChild);
+
+       var flash_object = 
+           this.get_flash_video_object(object_data.linterna_magica_id, 
+                                       object_data.parent);
+
+       if (flash_object)
+       {
+           flash_object.style.setProperty("position", 
+                                          "relative", "important");
+       }
     }
 
     // Show HD links list. 
@@ -277,7 +293,10 @@
        document.getElementById("linterna-magica-video-object-"+
                                object_data.linterna_magica_id);
 
-    object_tag.style.setProperty("position","relative","important");
+    if (object_tag)
+    {
+       object_tag.style.setProperty("position","relative","important");
+    }
 
     // Fixes the height of the third parent element.  Fixes
     // replacement object visibility.
@@ -312,18 +331,7 @@
                                        "important");
     }
 
-    // Fix displacement of toggle_plugin link/button in vimeo
-    var toggle_plugin = 
-       document.getElementById("linterna-magica-toggle-plugin-"+
-                               object_data.linterna_magica_id);
-
-    if (toggle_plugin)
-    {
-       toggle_plugin.style.setProperty("top",
-                                       parseInt(object_data.height)+10+
-                                       "px", "important");
-    }
-
+   
     // The CSS rules hide parts of our elements
     object_data.parent.parentNode.style.
        setProperty("height", (parseInt(object_data.height)+26+
@@ -335,5 +343,19 @@
        setProperty("width", (parseInt(object_data.width+2))+"px",
                    "important");
 
+    var site_html5_player = 
+       this.find_site_html5_player_wrapper(object_data.parent);
+
+    if (site_html5_player)
+    {
+       // The HTML5 player's thumbnail image has black lines on top and
+       // back after adding LM. Clear them
+       site_html5_player.style.setProperty("height", "87%", "important");
+
+       // The LM switch button is too close to the thumbnail of the HTML5 
player.
+       site_html5_player.style.setProperty("margin-bottom", 
+                                           "5px", "important");
+    }
+
     return false;
 }

Modified: trunk/src/lm_site_youtube.js
===================================================================
--- trunk/src/lm_site_youtube.js        2011-07-30 09:34:04 UTC (rev 170)
+++ trunk/src/lm_site_youtube.js        2011-08-01 17:57:18 UTC (rev 171)
@@ -220,6 +220,22 @@
 LinternaMagica.prototype.sites["www.youtube-nocookie.com"] = "youtube.com";
 LinternaMagica.prototype.sites["youtube-nocookie.com"] = "youtube.com";
 
+// Referenced by Vimeo
+LinternaMagica.prototype.sites["youtube.com"].flash_plugin_installed =
+function()
+{
+    var site_html5_player = this.find_site_html5_player_wrapper(document);
+
+    // If there is html5 player and flash plugin is installed no SWF
+    // object will be created. We must examine scripts.
+    if (site_html5_player)
+    {
+       return this.sites.__no_flash_plugin_installed.apply(this, [arguments]);
+    }
+
+    return true;
+}
+
 LinternaMagica.prototype.sites["youtube.com"].set_cookies_domain =
 function()
 {
@@ -502,6 +518,20 @@
      // Bug #33504 https://savannah.nongnu.org/bugs/?33504
     object_data.parent.style.setProperty("overflow", "visible", "important");
 
+    var site_html5_player = 
+       this.find_site_html5_player_wrapper(object_data.parent);
 
+    if (site_html5_player)
+    {
+       // The HTML5 player's controlls hide the Linterna Magica switch button.
+       site_html5_player.style.setProperty("margin-bottom", "30px", 
"important");
+
+       // The player is too close to YT visitors counter & buttons
+       object_data.parent.style.setProperty("margin-bottom",
+                                                "50px", "important");
+       
+    }
+    
+
     return false;
 }

Modified: trunk/src/lm_video_and_flash_objects_helper_functions.js
===================================================================
--- trunk/src/lm_video_and_flash_objects_helper_functions.js    2011-07-30 
09:34:04 UTC (rev 170)
+++ trunk/src/lm_video_and_flash_objects_helper_functions.js    2011-08-01 
17:57:18 UTC (rev 171)
@@ -203,3 +203,103 @@
 
     return started;
 }
+
+// Search for <video> or <canvas> (some sites use it alongside
+// <video>) in the parent and return its parentNode that is child of
+// parent.
+LinternaMagica.prototype.find_site_html5_player_wrapper =
+function(parent)
+{
+    if (!parent)
+    {
+       return null;
+    }
+
+    var html5_player_holder = null;
+    var t = null;
+
+    var video_or_canvas = parent.getElementsByTagName("video");
+
+    if (!video_or_canvas || !video_or_canvas.length)
+    {
+       // Some pages (Vimeo, Dailymotion might use a canvas tag
+       // before inserting the video tag). 
+       video_or_canvas  =  parent.getElementsByTagName("canvas");
+
+       // No more guesses
+       if (!video_or_canvas || !video_or_canvas.length)
+       {
+           return null;
+       }
+    }
+
+    html5_player_holder = video_or_canvas[0].parentNode;
+
+    // Searching for the holder element that is placed in the
+    // parent element (parent) that holds Linterna Magica.
+    while (parent != html5_player_holder)
+    {
+       t = html5_player_holder;
+       html5_player_holder = html5_player_holder.parentNode;
+    }
+
+    if (t !== null)
+    {
+       html5_player_holder = t;
+    }
+
+    return html5_player_holder;
+}
+
+// Hide the HTML5 player wrapper found in the parent element.
+LinternaMagica.prototype.hide_site_html5_player =
+function(parent)
+{    
+    var html5_player =
+       this.find_site_html5_player_wrapper(parent);
+
+    if (!html5_player)
+    {
+       return null;
+    }
+
+    html5_player.style.setProperty("display", "none", "important");
+    return html5_player;
+}
+
+// Show the HTML5 player wrapper found in the parent element.
+LinternaMagica.prototype.show_site_html5_player =
+function(parent)
+{
+
+    var html5_player =
+       this.find_site_html5_player_wrapper(parent);
+
+    if (!html5_player)
+    {
+       return null;
+    }
+
+    html5_player.style.removeProperty("display");
+    return html5_player;
+}
+
+// Pause the first HTML5 player (<video>) found in the parent element.
+LinternaMagica.prototype.pause_site_html5_player =
+function(parent)
+{
+    if (!parent)
+    {
+       return null;
+    }
+
+    var video = parent.getElementsByTagName("video");
+
+    if (!video || !video.length)
+    {
+       return null;
+    }
+
+    video = video[0];
+    video.pause();
+}

Modified: trunk/utilities/linternamagica_user_config.user.js
===================================================================
--- trunk/utilities/linternamagica_user_config.user.js  2011-07-30 09:34:04 UTC 
(rev 170)
+++ trunk/utilities/linternamagica_user_config.user.js  2011-08-01 17:57:18 UTC 
(rev 171)
@@ -41,7 +41,7 @@
     "debug": 0,
     "log_to": "web",
     "updates": "1w",
-    "priority": "self",
+    "priority": "html5, self, plugin",
     "autostart": "on",
     "controls": "self",
     "locale": "auto",




reply via email to

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