Among the many Flash-based video players that exist, a current project introduced me to FLV Scrubber, a CC licensed player which is not supported anymore by its author.
Currently, pywb is not rewriting the HTML this player requires.
The "variables" for the player can be handed to Flash movie in two ways (in both cases, DOM excerpts are rewritten by pywb already):
Here the FLV video file the player should show is listed as part of the URL of the flash player, in the "movie" <param> for the <object> and the "source" attribute of <embed>.
Here, the parameters which are handed over to the Flash video player are separated as both a "flashvars" <param> tag and a "flashvars" attribute of the <embed> tag.
Client-Side rewrite
By injecting this script into the collection's banner, I was able to rewrite the HTML so the videos play in Chrome and Firefox (with Flash plugin):
document.addEventListener('readystatechange', function(event) {
if (document.readyState !== 'interactive') return true; // only run once
// replace the offending absolute URL in any string
var replaceURL = function(str) {
return str.replace('http://mw.smokinggun.com/', wbinfo.prefix + wbinfo.request_ts + '/mw.smokinggun.com/');
}
// find all <object> nodes.
// The typical use of <object> is to embed plugins into a web page.
// As far as I know, only legacy versions of Internet Explorer uses this to
// embed the ActiveX variation of the Flash plugin.
// Both Firefox and Chrome use the <embed> nested within <object> apparently.
var objectNodes = document.querySelectorAll('object');
// Since the Flash plugin seems to be getting information from the DOM
// before the readystatechange triggers, the existing <object> nodes and
// their children <embed> nodes are cloned. the clones' attributes are rewritten,
// then the original nodes are replaced by the rewritten clones.
// This forces the Flash plugin to re-read the information.
// Because only legacy versions of Internet care about the <object> tag
// in this case, I did not manipulate the information in the nested <param>
// tags.
var objectNodesCloned = [];
for (var i=0; i<objectNodes.length; i++) {
objectNodesCloned.push( {source: objectNodes[i], clone: objectNodes[i].cloneNode(true) } );
}
objectNodesCloned.forEach(function(obj, index){
var embedNodes = obj.clone.querySelectorAll('embed');
for (var i=0; i<embedNodes.length; i++) {
['flashvars', 'src'].forEach(function(attrName){
if(embedNodes[i].hasAttribute(attrName)) {
str = replaceURL( embedNodes[i].getAttribute(attrName) );
embedNodes[i].setAttribute(attrName, str);
// the video URL might be encoded inside the source string as well.
// In this case, separate the videos URL into "flashvars" and
// keep the original "player movie" at the same URL.
// This is mostly due to how the FLV videos were archived,
// that is, by scraping them from their server. So their URLs need
// to be noted independently from the URL of the movie player.
if (attrName == 'src') {
if (str.indexOf('?') > -1) {
var URLparts = str.split('?');
embedNodes[i].setAttribute('src', URLparts[0]);
embedNodes[i].setAttribute('flashvars', URLparts[1]);
}
}
}
});
}
obj.source.parentNode.replaceChild(obj.clone, obj.source);
});
});
Among the many Flash-based video players that exist, a current project introduced me to FLV Scrubber, a CC licensed player which is not supported anymore by its author.
Currently, pywb is not rewriting the HTML this player requires.
The "variables" for the player can be handed to Flash movie in two ways (in both cases, DOM excerpts are rewritten by pywb already):
1. URL Param Style
Here the FLV video file the player should show is listed as part of the URL of the flash player, in the "movie"
<param>
for the<object>
and the "source" attribute of<embed>
.2. Separated URL
Here, the parameters which are handed over to the Flash video player are separated as both a "flashvars"
<param>
tag and a "flashvars" attribute of the<embed>
tag.Client-Side rewrite
By injecting this script into the collection's banner, I was able to rewrite the HTML so the videos play in Chrome and Firefox (with Flash plugin):