package
{
import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.net.*;
import flash.system.*;
import flash.utils.*;
public class BrightcoveBootloader extends Sprite
{
private var _player:Object;
private var _playerLoader:Loader;
private var _flashVars:Object;
private var _downloadStartTime:int;
private var _dataDelta:int;
private const _cookieName:String = "BC_BANDWIDTH";
private var _cookieContents:Array;
public function BrightcoveBootloader()
{
this._flashVars = root.loaderInfo.parameters;
Security.allowDomain("*");
this._flashVars.startTime = getTimer();
var _loc_1:String;
if (this._flashVars.secureConnections == "true")
{
_loc_1 = "https://sadmin.brightcove.com/viewer/us20120824.1350/";
}// end if
if (this._flashVars.isSlim != null)
{
_loc_1 = _loc_1 + "federatedSlim";
}
else if (this._flashVars.isVid != null)
{
if (this._flashVars.isUI != null)
{
_loc_1 = _loc_1 + "federatedVideoUI";
}
else
{
_loc_1 = _loc_1 + "federatedVideo";
}// end else if
}
else if (this._flashVars.isAudio != null)
{
if (this._flashVars.isUI != null)
{
_loc_1 = _loc_1 + "federatedAudioUI";
}
else
{
_loc_1 = _loc_1 + "federatedAudio";
}// end else if
}
else if (this._flashVars.isUI != null)
{
_loc_1 = _loc_1 + "federatedUI";
}
else
{
_loc_1 = _loc_1 + "federated";
}// end else if
this._flashVars.cookieComments = [];
this.initializeUniqueSWFIdentifier();
this._playerLoader = new Loader();
this._playerLoader.contentLoaderInfo.addEventListener(Event.INIT, this.onPlayerLoadInit);
this._playerLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, this.progressHandler);
this._playerLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.completeHandler);
this._playerLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.errorHandler);
this._playerLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.errorHandler);
var _loc_2:* = new LoaderContext();
_loc_2.applicationDomain = ApplicationDomain.currentDomain;
_loc_2.securityDomain = SecurityDomain.currentDomain;
var _loc_3:* = this._flashVars.useClientSideBandwidthDetection != "false";
if (_loc_3)
{
this._playerLoader.load(new URLRequest(_loc_1 + "/BrightcovePlayer.swf?uid=" + this._flashVars.uniqueSWFIdentifier), _loc_2);
}
else
{
this._playerLoader.load(new URLRequest(_loc_1 + "/BrightcovePlayer.swf"), _loc_2);
}// end else if
return;
}// end function
private function errorHandler(param1:Event) : void
{
this.removeListeners();
return;
}// end function
private function progressHandler(param1:ProgressEvent) : void
{
if (param1.bytesLoaded > 0)
{
this._dataDelta = param1.bytesTotal - param1.bytesLoaded;
this._downloadStartTime = new Date().getTime();
param1.target.removeEventListener(ProgressEvent.PROGRESS, this.progressHandler);
}// end if
return;
}// end function
private function completeHandler(param1:Event) : void
{
var _loc_2:int;
this.removeListeners();
var _loc_3:int;
if (!this._cookieContents)
{
_loc_2 = new Date().getTime() - this._downloadStartTime;
_loc_3 = this._dataDelta / _loc_2 * (8000 / 1024);
this._flashVars.bandwidth = _loc_3;
this._flashVars.cookieComments.push("Bandwidth calculated from SWF download: " + _loc_3 + " Kbps " + "(time= " + _loc_2 + " ms, size= " + this._dataDelta + " bytes)");
}// end if
this._player.initialize(this._flashVars);
return;
}// end function