[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [237] Support for JWPlayer and Indieflix.com
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [237] Support for JWPlayer and Indieflix.com |
Date: |
Sun, 08 Jan 2012 19:56:48 +0000 |
Revision: 237
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=237
Author: valkov
Date: 2012-01-08 19:56:47 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
Support for JWPlayer and Indieflix.com
Modified Paths:
--------------
trunk/src/lm_extract_js_scripts.js
trunk/src/lm_forbidden_objects.js
trunk/src/lm_interface_toggle_plugin.js
trunk/src/lm_video_and_flash_objects_helper_functions.js
Added Paths:
-----------
trunk/src/lm_extract_js_jwplayer.js
trunk/src/lm_site_indieflixcom.js
Added: trunk/src/lm_extract_js_jwplayer.js
===================================================================
--- trunk/src/lm_extract_js_jwplayer.js (rev 0)
+++ trunk/src/lm_extract_js_jwplayer.js 2012-01-08 19:56:47 UTC (rev 237)
@@ -0,0 +1,157 @@
+// @licstart The following is the entire license notice for the
+// JavaScript code in this page (or file).
+//
+// This file is part of Linterna Mágica
+//
+// Copyright (C) 2011, 2012 Ivaylo Valkov <address@hidden>
+//
+// The JavaScript code in this page (or file) is free software: you
+// can redistribute it and/or modify it under the terms of the GNU
+// General Public License (GNU GPL) as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option)
+// any later version. The code is distributed WITHOUT ANY WARRANTY
+// without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
+//
+// As additional permission under GNU GPL version 3 section 7, you
+// may distribute non-source (e.g., minimized or compacted) forms of
+// that code without the copy of the GNU GPL normally required by
+// section 4, provided you include this license notice and a URL
+// through which recipients can access the Corresponding Source.
+//
+// @licend The above is the entire license notice for the JavaScript
+// code in this page (or file).
+//
+// @source http://linterna-magica.nongnu.org
+
+// END OF LICENSE HEADER
+
+// Extracts object data for flash objects created with flowplayer
+// flash player/library.
+LinternaMagica.prototype.extract_object_from_script_jwplayer = function()
+{
+ var constructor_re = new RegExp(
+ ".*jwplayer\\\((\\\"|\\\')(\\\w+)(\\\"|\\\')\\\)\\\.setup",
+ "im");
+
+ var data = this.script_data;
+
+ var constructor = data.match(constructor_re);
+ var el, width, height;
+ var object_data = new Object();
+
+ if (!constructor)
+ {
+ return null;
+ }
+
+ el = constructor[2];
+ el = document.getElementById(el);
+
+ if (!el)
+ {
+ this.log("LinternaMagica.extract_object_from_script_jwplayer:\n"+
+ "No player holder element found with id "+el,4);
+
+ return null;
+ }
+
+ width = data.match(/width:\s*([0-9]+),/);
+ height = data.match(/height:\s*([0-9]+),/);
+
+ if (width)
+ {
+ width = width[1];
+ }
+ else
+ {
+ width = el.clientWidth ? el.clientWidth: el.offsetWidth;
+ }
+
+ if (height)
+ {
+ height = height[1];
+ }
+ else
+ {
+ height = el.clientHeight ? el.clientHeight: el.offsetHeight;
+ }
+
+
+ if (! width || ! height)
+ {
+ return null;
+ }
+
+ object_data.parent = el;
+ object_data.width = width;
+ object_data.height = height;
+
+ var hd = this.extract_jwplayer_hd_links(data);
+
+ object_data.hd_links = (hd && hd.length) ? hd : null;
+ object_data.link = (hd && hd.length) ? hd[hd.length-1].url : null;
+
+ if (object_data.link)
+ {
+ object_data.linterna_magica_id =
+ this.mark_flash_object("extracted-from-script");
+
+ return object_data;
+ }
+
+ return null;
+}
+
+LinternaMagica.prototype.extract_jwplayer_hd_links = function(data)
+{
+ var hd_links_re = new RegExp (
+ "levels(\\\"|\\\')*\\\s*:\\\s*\\\[.*",
+ "img");
+
+ var links_data = data.match(hd_links_re);
+
+ if (!links_data || !links_data.length)
+ {
+ return null;
+ }
+
+ links_data = links_data[0];
+
+ hd_links_re = new RegExp (
+ "\\\{[^\\\}]+",
+ "img");
+
+ var count = 0;
+ var hd_links = new Array();
+
+ var link_data = null;
+
+ while (link_data = hd_links_re.exec(links_data))
+ {
+ count++;
+
+ var link = new Object();
+
+ this.extract_link_data = link_data[0];
+ link.url = this.extract_link();
+
+ var label = link_data[0].match(/width(\"|\')*\s*:\s*([0-9]+),/);
+
+ if (!label)
+ {
+ // Translators: This is a label for HD link. It is
+ // followed by a number.
+ label = this._("Link") + " " + count;
+ }
+ else
+ {
+ label = label[label.length-1] +"p";
+ }
+
+ link.label = label;
+ hd_links.push(link);
+ }
+
+ return hd_links;
+}
Modified: trunk/src/lm_extract_js_scripts.js
===================================================================
--- trunk/src/lm_extract_js_scripts.js 2012-01-08 09:56:08 UTC (rev 236)
+++ trunk/src/lm_extract_js_scripts.js 2012-01-08 19:56:47 UTC (rev 237)
@@ -3,7 +3,7 @@
//
// This file is part of Linterna Mágica
//
-// Copyright (C) 2010, 2011 Ivaylo Valkov <address@hidden>
+// Copyright (C) 2010, 2011, 2012 Ivaylo Valkov <address@hidden>
// Copyright (C) 2010 Anton Katsarov <address@hidden>
//
// The JavaScript code in this page (or file) is free software: you
@@ -116,6 +116,12 @@
if (!object_data)
{
object_data =
+ this.extract_object_from_script_jwplayer();
+ }
+
+ if (!object_data)
+ {
+ object_data =
this.extract_object_from_script_pokkariplayer();
}
Modified: trunk/src/lm_forbidden_objects.js
===================================================================
--- trunk/src/lm_forbidden_objects.js 2012-01-08 09:56:08 UTC (rev 236)
+++ trunk/src/lm_forbidden_objects.js 2012-01-08 19:56:47 UTC (rev 237)
@@ -3,7 +3,7 @@
//
// This file is part of Linterna Mágica
//
-// Copyright (C) 2010, 2011 Ivaylo Valkov <address@hidden>
+// Copyright (C) 2010, 2011, 2012 Ivaylo Valkov <address@hidden>
// Copyright (C) 2010 Anton Katsarov <address@hidden>
//
// The JavaScript code in this page (or file) is free software: you
@@ -35,6 +35,8 @@
"flashRateObject", "VideoCharts",
// Facebook iframes in blip.tv
"^f[0-9]+[a-z]+",
+ // Facebook frame at Indieflix.com
+ "^fb[0-9]+[a-z]+",
// Blip.tv objects
"easyXDM_DISQUS_net_default[0-9]+_provider",
// livestream.com
Modified: trunk/src/lm_interface_toggle_plugin.js
===================================================================
--- trunk/src/lm_interface_toggle_plugin.js 2012-01-08 09:56:08 UTC (rev
236)
+++ trunk/src/lm_interface_toggle_plugin.js 2012-01-08 19:56:47 UTC (rev
237)
@@ -3,7 +3,7 @@
//
// This file is part of Linterna Mágica
//
-// Copyright (C) 2010, 2011 Ivaylo Valkov <address@hidden>
+// Copyright (C) 2010, 2011, 2012 Ivaylo Valkov <address@hidden>
// Copyright (C) 2010 Anton Katsarov <address@hidden>
//
// The JavaScript code in this page (or file) is free software: you
@@ -62,6 +62,7 @@
wrapper = document.createElement("p");
wrapper.appendChild(toggle_plugin);
wrapper.style.setProperty("position", "relative", "important");
+ wrapper.style.setProperty("z-index", "999999", "important");
}
else
{
Added: trunk/src/lm_site_indieflixcom.js
===================================================================
--- trunk/src/lm_site_indieflixcom.js (rev 0)
+++ trunk/src/lm_site_indieflixcom.js 2012-01-08 19:56:47 UTC (rev 237)
@@ -0,0 +1,132 @@
+// @licstart The following is the entire license notice for the
+// JavaScript code in this page (or file).
+//
+// This file is part of Linterna Mágica
+//
+// Copyright (C) 2011, 2012 Ivaylo Valkov <address@hidden>
+//
+// The JavaScript code in this page (or file) is free software: you
+// can redistribute it and/or modify it under the terms of the GNU
+// General Public License (GNU GPL) as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option)
+// any later version. The code is distributed WITHOUT ANY WARRANTY
+// without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
+//
+// As additional permission under GNU GPL version 3 section 7, you
+// may distribute non-source (e.g., minimized or compacted) forms of
+// that code without the copy of the GNU GPL normally required by
+// section 4, provided you include this license notice and a URL
+// through which recipients can access the Corresponding Source.
+//
+// @licend The above is the entire license notice for the JavaScript
+// code in this page (or file).
+//
+// @source http://linterna-magica.nongnu.org
+
+// END OF LICENSE HEADER
+
+LinternaMagica.prototype.sites["indieflix.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.indieflix.com"] = "indieflix.com";
+
+LinternaMagica.prototype.sites["indieflix.com"].custom_html5_player_finder =
+function(parent)
+{
+ var html5_player_element = null;
+
+ html5_player_element =
+ document.getElementById("player_displayarea");
+
+ return html5_player_element;
+}
+
+LinternaMagica.prototype.sites["indieflix.com"].do_not_force_iframe_detection =
+function()
+{
+ return false;
+}
+
+LinternaMagica.prototype.sites["indieflix.com"].css_fixes =
+function(object_data)
+{
+ var id = object_data.linterna_magica_id;
+ var toggle_plugin =
+ document.getElementById("linterna-magica-toggle-plugin-"+id);
+
+ if (toggle_plugin)
+ {
+ // Move the external toggle plugin link at the bottom of the
+ // player.
+ var p = toggle_plugin.parentNode;
+ p.style.setProperty("top", (parseInt(object_data.height)+5)+"px",
+ "importnat");
+ }
+
+ // Fix hidden HD links menu
+ var lm = document.getElementById("linterna-magica-"+id);
+ var central_player = lm.parentNode.parentNode;
+
+ if (central_player)
+ {
+ central_player.style.setProperty("overflow", "visible",
+ "important");
+ }
+
+ // Page element overlaps the LM elements. Fix it.
+ lm.style.setProperty("z-index", "99999999", "important");
+
+ return false;
+}
+
+// An attempt to support Midori 0.4.0. The JWPlayer script loads
+// slowly than LM and replaces it. Most of the time Midori 0.4.0 hangs
+// or crashes here.
+LinternaMagica.prototype.sites["indieflix.com"].
+replace_extracted_object_from_script =
+function(object_data)
+{
+ if (!this.indieflix_html5_element_timeout)
+ {
+ this.log("LinternaMagica.sites.replace_extracted_"+
+ "object_from_script:\n"+
+ "Delaying video object creation in Indieflix.",3);
+ this.indieflix_html5_element_counter = 0;
+ var data = object_data;
+ var self = this;
+
+ this.indieflix_html5_element_timeout =
+ setInterval(function() {
+ self.detect_indieflix_html5_element.
+ apply(self,[data]);
+ }, 2000);
+ }
+ return false;
+}
+
+LinternaMagica.prototype.detect_indieflix_html5_element =
+function(object_data)
+{
+ this.indieflix_html5_element_counter++;
+
+ var html5_element =
+ this.find_site_html5_player_wrapper(object_data.parent);
+ var insert_object = null;
+
+ // 2 seconds at once
+ if (this.indieflix_html5_element_counter >= 1 || html5_element)
+ {
+ clearInterval(this.indieflix_html5_element_timeout);
+
+ this.log("LinternaMagica.detect_indieflix_html5_element:\n"+
+ "Removing plugin install warning.",2);
+
+ this.remove_plugin_install_warning(object_data.parent);
+
+ this.log("LinternaMagica.detect_indieflix_html5_element:\n"+
+ "Creating video object.",2);
+
+ this.create_video_object(object_data);
+ }
+}
Modified: trunk/src/lm_video_and_flash_objects_helper_functions.js
===================================================================
--- trunk/src/lm_video_and_flash_objects_helper_functions.js 2012-01-08
09:56:08 UTC (rev 236)
+++ trunk/src/lm_video_and_flash_objects_helper_functions.js 2012-01-08
19:56:47 UTC (rev 237)
@@ -3,7 +3,7 @@
//
// This file is part of Linterna Mágica
//
-// Copyright (C) 2011 Ivaylo Valkov <address@hidden>
+// Copyright (C) 2011, 2012 Ivaylo Valkov <address@hidden>
//
// The JavaScript code in this page (or file) is free software: you
// can redistribute it and/or modify it under the terms of the GNU
@@ -256,6 +256,15 @@
while (parent != html5_player_holder)
{
t = html5_player_holder;
+
+ // Fix crashing and strange behaviour in Midori 0.4.0
+ // Complains on html5_player_holder.parentNode; about
+ // html5_player_holder not being an object.
+ if (!html5_player_holder)
+ {
+ continue;
+ }
+
html5_player_holder = html5_player_holder.parentNode;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [237] Support for JWPlayer and Indieflix.com,
Ivaylo Valkov <=