extension/content.js
/* 
	Sends JS script to video player iframe to attach an event to the 
	player, to call back to us when video position changes.
	Cannot directly get JS vars from iframe (domain security), but
	adopting a script element and running it will work.
*/
Sends JS script to video player iframe to attach an event to the
player, to call back to us when video position changes.
Cannot directly get JS vars from iframe (domain security), but
adopting a script element and running it will work.
Sends JS script to video player iframe to attach an event to the player to call back to us when video position changes . Cannot directly get JS vars from iframe ( domain security ) but adopting a script element and running it will work .
function SetupPositionWatcher(playerWindow)
{
	var elem = playerWindow.document.createElement("script");
	elem.type = "text/javascript";
	var playerHtml = "var lastStored = null;var extensaionCallbackLocked = false;jwplayer(playerName).onTime(function(playerPosition){var currentDate = new Date();if(extensaionCallbackLocked === false && (lastStored === null || Math.abs((currentDate.getTime() - lastStored.getTime()) / 1000) > 1)){lastStored = currentDate;extensaionCallbackLocked = true;parent.postMessage(JSON.stringify(playerPosition),'http://superbestfriendsplay.com/');extensaionCallbackLocked = false;}});";
	elem.innerHTML = playerHtml;					
	playerWindow.document.head.appendChild(elem);
}
function SetupPositionWatcher ( playerWindow ) { var elem = playerWindow . document . createElement ( "script" ) ; elem . type = "text/javascript" ; var playerHtml = "var lastStored = null;var extensaionCallbackLocked = false;jwplayer(playerName).onTime(function(playerPosition){var currentDate = new Date();if(extensaionCallbackLocked === false && (lastStored === null || Math.abs((currentDate.getTime() - lastStored.getTime()) / 1000) > 1)){lastStored = currentDate;extensaionCallbackLocked = true;parent.postMessage(JSON.stringify(playerPosition),'http://superbestfriendsplay.com/');extensaionCallbackLocked = false;}});" ; elem . innerHTML = playerHtml ; playerWindow . document . head . appendChild ( elem ) ; }
Sends JS script to video player iframe to attach an event to the
player, to call back to us when video position changes.
Sends JS script to video player iframe to attach an event to the player to call back to us when video position changes .
//Setup passthrough - will post message cross-browser on position change //Post once per second max, and lock while processing is happening to stop doubling up.