POIA in HELP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Integrated Senate Video Player</title>
<style type="text/css">
#akamai-media-player
{
width: 100%; height: 100%;
position: absolute; top: 0; left: 0;
}
</style>
<script type="text/javascript" src="http://www.senate.gov/isvp/amp/amp.min.js?amp-defaults=config.xml"></script>
<script src ="jquery-1.11.0.min.js">//Used for refreshing the DIV element in Internet explorer</script>
<script type="text/javascript">
//this function is used to pare the URL to retrieve parameters to determine which video to play.
function getParameter(paramName) {
var searchString = window.location.search.substring(1),
i, val, params = searchString.split("&");

for (i=0;i<params.length;i++) {
val = params[i].split("=");
if (val[0] == paramName) {
return unescape(val[1]);
}
}
return null;
}
//Function to parse the time into seconds for the stt and dur url queries. The possible time formats are [seconds], [mm:ss], and [hh:mm:ss]
function parseTime(str) {
var parse = str.split(':'),
s = 0, m = 1;

while (parse.length > 0) {
s += m * parseInt(parse.pop(), 10);
m *= 60;
}
return s;
}
//Calling the getParameter function to get the appropriate parameters for the video source.
//Get type parameter from URL for Live or Archive streams
var type = getParameter('type');
//Get comm parameter to determine the committee
var comm = getParameter('comm');
//Get the filename parameter to get the proper stream
var filename = getParameter('filename');
//Get auto_play parameter so the video plays automatically or not (by default videos are set to play automatically. This is done in the function autoPlay)
var auto = getParameter('auto_play');
//Show a poster before the video is played. If playing flash, this works if a properly configured crossdomain.xml is placed at the root of the site the poster is being pulled from. If playing html, none of this configuration is needed. Link for configuring crossdomain.xml can be found here. http://kb2.adobe.com/cps/142/tn_14213.html
var urlPoster = getParameter('poster');
//Get the stt paramter to start the video, needs to be in a specified time format: [seconds]|[mm:ss]|[hh:mm:ss]
var stt = getParameter('stt');
//Get the dur paramter to stop the video, needs to be in a specified time format: [seconds]|[mm:ss]|[hh:mm:ss]
var dur = getParameter('dur');
//Converts stt parameter to seconds
if (stt === null) {
var sttSec = 0;
} else {
var sttSec = parseTime(stt);
}
//Converts dur paramter to seconds
if (dur === null) {
var durSec = 0;
} else {
var durSec = parseTime(dur);
}
//Workaround to stop buffering issue when playing live video with auto_play set to false and a stt parameter
if (auto==="false" && type==="live" && stt!==null)// && type==="live" && sttSec!=null)
{
//console.log(stt);
type= "arch";
}
// Determines if the video will autoplay or not. If no parameters are specified the video will autoplay by default. Otherwise the parameters will determine if the video autoplays or not.
function autoPlay(auto){
if (auto === null){
return true;
}else {
return auto;
}
}
//Array of committee names, corresponding Akamai stream numbers and appropriate domains. Listed one stream per line for easy reading and editing if needed
var streamInfo = new Array
(
["ag", "76440", "http://ag-f.akamaihd.net"],
["aging", "76442", "http://aging-f.akamaihd.net"],
["approps", "76441", "http://approps-f.akamaihd.net"],
["armed", "76445", "http://armed-f.akamaihd.net"],
["banking", "76446", "http://banking-f.akamaihd.net"],
["budget", "76447", "http://budget-f.akamaihd.net"],
["cecc", "76486", "http://srs-f.akamaihd.net"],
["commerce", "80177", "http://commerce1-f.akamaihd.net"],
["csce", "75229", "http://srs-f.akamaihd.net"],
["dpc", "76590", "http://dpc-f.akamaihd.net"],
["energy", "76448", "http://energy-f.akamaihd.net"],
["epw", "76478", "http://epw-f.akamaihd.net"],
["ethics", "76449", "http://ethics-f.akamaihd.net"],
["finance", "76450", "http://finance-f.akamaihd.net"],
["foreign", "76451", "http://foreign-f.akamaihd.net"],
["govtaff", "76453", "http://govtaff-f.akamaihd.net"],
["help", "76452", "http://help-f.akamaihd.net"],
["indian", "76455", "http://indian-f.akamaihd.net"],
["intel", "76456", "http://intel-f.akamaihd.net"],
["intlnarc", "76457", "http://intlnarc-f.akamaihd.net"],
["jccic", "85180", "http://jccic-f.akamaihd.net"],
["jec", "76458", "http://jec-f.akamaihd.net"],
["judiciary", "76459", "http://judiciary-f.akamaihd.net"],
["rpc", "76591", "http://rpc-f.akamaihd.net"],
["rules", "76460", "http://rules-f.akamaihd.net"],
["saa", "76489", "http://srs-f.akamaihd.net"],
["smbiz", "76461", "http://smbiz-f.akamaihd.net"],
["srs", "75229", "http://srs-f.akamaihd.net"],
["uscc", "76487", "http://srs-f.akamaihd.net"],
["vetaff", "76462", "http://vetaff-f.akamaihd.net"],
["arch", "", "http://ussenate-f.akamaihd.net/"]
);
// Iterates the array looking for comm which is defined in the url parameters. If the committee name is found the j variable is increased by 1 to provide the Akamai stream number, and then j variable is also increased by 2 to provide the specific Akamai domain for the committee stream.
for (var i = 0; i <streamInfo.length; i++) {
for (var j = 0; j < streamInfo[i].length; j++){
if (streamInfo[i][j] === comm) {
var streamNum = streamInfo[i][j+1];
var streamDomain = streamInfo[i][j+2];
break;
}else if (streamInfo[i][j] === type) {
var streamArch = streamInfo[i][j+2];
break;
}
}
}
var fellback = 0; //Defaults fellback to 0.
var fallbackArray = []; //Allows function fallback to try different streams
//Default arch filetype to .mp4 if no extension specified in filename before URL is passed to player
if(type==="arch" && filename.split(".")[1]===undefined)
{
filename = filename + ".mp4";
}
//Determines whether the video is in archive or live
var asourceType = "/manifest.f4m";
var isourceType = "/master.m3u8";
var liveA = streamDomain + "/z/" + filename + "_1@" + streamNum + asourceType;
var liveI = streamDomain + "/i/" + filename + "_1@" + streamNum + isourceType;
var archA = streamArch + filename;
var archI = streamArch + filename;
if (type === "arch"){
AURL = archA;
IURL = archI;
}else if (type === "live"){
AURL = liveA;
IURL = liveI;
}else {
AURL = liveA;
IURL = liveI;
}
function generateFallbacks(errorHandler) //The order of the fallbacks depending on what variables are specified in the URL query.
{
if(type==="arch" && filename.indexOf(".mp4")!=-1) //archive.mp4 (default if no extension specified)
{
fallbackArray[1]={type:'arch', 'filename': filename.replace(".mp4",".flv")};
fallbackArray[0]={type:'live', 'filename': filename.split(".")[0]};
fallbackArray[2]={type:'error', 'filename': filename.split(".")[0]};

}
else if(type==="arch" && filename.indexOf(".flv")!=-1) //archive.flv
{
fallbackArray[1]={type:'arch','filename': filename.replace(".flv",".mp4")};
fallbackArray[0]={type:'live','filename': filename.split(".")[0]};
fallbackArray[2]={type:'error', 'filename': filename.split(".")[0]};
}
else if(type==="live") //live[.mp4||.flv]
{
var prefix = filename.split(".")[0];
fallbackArray[0]={type:'arch','filename': prefix + ".mp4"};
fallbackArray[1]={type:'arch', 'filename': prefix + ".flv"};
fallbackArray[2]={type:'live','filename': prefix};
fallbackArray[3]={type:'error', 'filename': filename.split(".")[0]};
}
return fallback();
}
function fallback() //Changes the filename depending on what value is in the fallbackArray
{
if(fellback<fallbackArray.length)
{
var filename = fallbackArray[fellback].filename;
auto = true;
switch(fallbackArray[fellback].type)
{
case 'live':
AURL = streamDomain + "/z/" + filename + "_1@" + streamNum + asourceType;
IURL = streamDomain + "/i/" + filename + "_1@" + streamNum + isourceType;
break;
case 'arch':
AURL = "http://ussenate-f.akamaihd.net/" + filename;
IURL = "http://ussenate-f.akamaihd.net/" + filename;
break;
case 'error': //points to fake file named "error" on netstorage.
AURL = "http://ussenate-f.akamaihd.net/error";
IURL = "http://ussenate-f.akamaihd.net/error";
}
fellback++;
reloadMediaPlayer();
}
else
{
fellback = -1
AURL = "http://ussenate-f.akamaihd.net/error";
IURL = "http://ussenate-f.akamaihd.net/error";
reloadMediaPlayer();
}
}
function reloadMediaPlayer()
{
if (navigator.userAgent.toLowerCase().indexOf('trident') >-1) //Checks if the browser is internet explorer
{
$( "#akamai-media-player").empty(); //this is required in internet explorer to refresh the div for video to display properly
loadHandler();
}else
{
loadHandler(); // if somebody is using a browser other than IE
}
}
//Below is the function that calls the video player. The only variables that need to be passed to this function are those that are required to create the appropriate source URL from the parameters provided (AURL and IURL).
var amp;
var currentTimeChecker;
var hasSeeked;
function loadHandler(event)
{
var config_overrides =
{
autoplay: autoPlay(auto),
media:
{
poster: urlPoster,
source:
[
{src: AURL, type: "video/f4m"},
{src: IURL, type: "application/x-mpegURL"}
],
track:
[
{kind: "captions", type: "live-oncaptioninfo", src:""}
]
},
captioning:
{
enabled: true
},
mediaanalytics:
{
enabled: true
}

};
amp = new akamai.amp.AMP("akamai-media-player", config_overrides);
amp.addEventListener("error", errorHandler);
amp.addEventListener("canplaythrough", startHandler);
amp.addEventListener("timeupdate", durationCheck);
};

function startHandler(event)//If the STT variable is defined in the URL the player will seek to that time specified.
{
if (sttSec > 0)
amp.setCurrentTime(sttSec);
}
function errorHandler(event) //Sends 4 error messages per error
{
amp.removeEventListener("error", errorHandler); //Only allows one error message through
generateFallbacks();
}
function durationCheck(event)
{
if (durSec > 0)
{
durationHandler();
}
}
function durationHandler(event)
{
currentTimeChecker = amp.getCurrentTime();

if (currentTimeChecker > durSec)
{
endHandler();
}
}
function endHandler(event)
{
amp.end();
}


</script>
</head>
<!-- HACK: ontouchstart="" is a workaround that enables the use of the CSS :active psuedo class on iOS -->
<body onload="loadHandler()" ontouchstart="">
<div id="akamai-media-player"></div>
</body>
</html>