/**** MAY 11, 2012 SCRIPT BELOW WAS HACKED TO ACCOMMODATE BOTH THE USE OF A TRANSCRIPT AND CUE POINTS THE CUEPOINTS JAVASCRIPT FILE CODE IS NOW INCLUDED AT THE BOTTOM OF THIS FILE. PART OF THE INCLUDED CODE IS AT THE BOTTOM OF THE onTemplateLoaded FUNCTION. ****/ //THIS ENTIRE SCRIPT IS JUST TO ENABLE LINKS TO BE CLICKED AND OPENED IN A NEW WINDOW. //IF A PAGE HAS A BRIGHTCOVE VIDEO IT WILL ENABLE A target="_self" EMULATION. //IF A PAGE HAS NO VIDEOS... IT CHECKS... THEN DOES NOTHING. //ONLY ADDS LISTENERS TO THE FLASH PLAYER... IT DOES NO DOM MANIPULATION. var bcExp; var modExp; var modCue; var modVid; var queuedTime; var bcplayer = 'avp' function onTemplateLoaded(bcplayer) { var bcExp2; var modVP; var modExp2; bcExp2 = brightcove.getExperience(bcplayer); modVP = bcExp2.getModule(APIModules.VIDEO_PLAYER); modExp2 = bcExp2.getModule(APIModules.EXPERIENCE); modExp2.addEventListener(BCExperienceEvent.TEMPLATE_READY, function onTemplateReady() { var currentVideo = modVP.getCurrentVideo(); //transcript var tlink = modExp2.getElementByID("transcriptLink"); if (tlink) { var Turl = currentVideo.customFields["transcriptlinkurl"]; tlink.addEventListener("elementClick", function onLinkClick(evt) { if (evt.elementID == "transcriptLink"){ window.location.href = Turl; } }//END onLinkClick );//END addEventListener }//END if //relatedlink1 (NOT CUSTOM FIELD) var r1link = modExp2.getElementByID("relatedLink"); if (r1link) { var R1url = currentVideo.linkURL; r1link.addEventListener("elementClick", function onLinkClick(evt) { if (evt.elementID == "relatedLink"){ window.location.href = R1url; } }//END onLinkClick );//END addEventListener }//END if //relatedlink2 var r2link = modExp2.getElementByID("relatedLink2"); if (r2link) { var R2url = currentVideo.customFields["relatedlink2url"]; r2link.addEventListener("elementClick", function onLinkClick(evt) { if (evt.elementID == "relatedLink2"){ window.location.href = R2url; } }//END onLinkClick );//END addEventListener }//END if //relatedlink3 var r3link = modExp2.getElementByID("relatedLink3"); if (r3link) { var R3url = currentVideo.customFields["relatedlink3url"]; r3link.addEventListener("elementClick", function onLinkClick(evt) { if (evt.elementID == "relatedLink3"){ window.location.href = R3url; } }//END onLinkClick ) //END addEventListener }//END if //allVidLink (NOT CUSTOM FIELD, JUST BANNER LINK) var avlink = modExp2.getElementByID("allVidLink"); if (avlink) { var allVidurl = "https://www.federalreserve.gov/mediacenter/media.htm"; avlink.addEventListener("elementClick", function onLinkClick(evt) { if (evt.elementID == "allVidLink"){ window.location.href = allVidurl; } }//END onLinkClick );//END addEventListener }//END if }//END onTemplateReady ); //END modExp2.addEventListener /**** BEGIN - CUEPOINTS INCLUDE ****/ //GET THE EXPERIENCE ID bcExp = brightcove.getExperience("myExperience" + modExp2.getPlayerParameter('@videoPlayer')); // get references to the modules we'll need modExp = bcExp.getModule(APIModules.EXPERIENCE); modCue = bcExp.getModule(APIModules.CUE_POINTS); modVid = bcExp.getModule(APIModules.VIDEO_PLAYER); // listen for the content load event so we can grab the videos cuepoints modExp.addEventListener(BCExperienceEvent.CONTENT_LOAD, onContentLoad); /**** END CUEPOINTS INCLUDE ****/ } //END onTemplateLoaded /**** BEGIN - CUEPOINTS INCLUDE ****/ /** * Called when the video content is loaded. */ function onContentLoad(event) { // reference to the chapter div which we'll put our links into var chaptersElem = document.getElementById("chapters"); // remove any previous links which already be in the div chaptersElem.innerHTML = ""; // get the list of cuepoints for the video var cuepoints = modCue.getCuePoints(modVid.getCurrentVideo().id); // loop over all the cuepoints for (var i = 0; i < cuepoints.length; i++) { // we're looking for "code" (type = 1) cuepoints, there will also be some // ad cuepoints in the list so check the type if (cuepoints[i].type == 1) { // only add the divider if at least one link has been added if (chaptersElem.children.length > 0) { chaptersElem.innerHTML += " "; } // dynamically add a new link for the current cuepoint chaptersElem.innerHTML += "<li><a href='javascript:void();' onclick='seek(" + cuepoints[i].time + ");'>" + cuepoints[i].name + "</a></li>"; } } } /** * Seeks to the given time in the video. */ function seek(time) { // it's not possible to seek unless the video is playing // so check to see if it's playing and if it's not then // save the time and tell the video to play if (modVid.isPlaying()) { modVid.seek(time); } else { queuedTime = time; modVid.addEventListener(BCMediaEvent.PROGRESS, onProgress); modVid.play(); } } /** * Called when the video starts playing. */ function onProgress(event) { // remove the progress event listener and seek to the saved time modVid.removeEventListener(BCMediaEvent.PROGRESS, onProgress); seek(queuedTime); } /**** END CUEPOINTS INCLUDE ****/