var app = angular.module('ngVideoPlayer', [])
//services
.factory('VideoPlayer', ['$rootScope', '$http', function ($rootScope, $http) {
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
var baseurl = (document.domain != "localhost") ? window.location.origin : "https://abcnews.go.com";
var isSecure = (baseurl.indexOf("https:") > -1)?true:false;
var feedUrlBase = (document.domain == "localhost") ? "http://"+window.location.host : baseurl;
var baseurl_assets = (/localhost/.test(window.location.origin))? "/demo/script?url=" : "https://s.abcnews.com/assets";
if(/qa.n7.abcnews.go.com/.test(window.location.origin)){
baseurl_assets = window.location.origin + "/assets"
}
var VideoPlayer = {
//player events
readyHandler : function(event){
//player is ready
VideoPlayer.broadcastEvent("ready", event);
//fire sitewide ready handler
abcn_ui.Helpers.video.globalReadyHandler(event);
//set up other listeners
event.player.addEventListener("canplay", function(event){VideoPlayer.broadcastEvent("can_play", event)});
event.player.addEventListener("playrequest", function(event){VideoPlayer.broadcastEvent("play_request", event)});
event.player.addEventListener("mediachange", function(event){abcn_ui.Helpers.video.globalMediaChangeHandler(event);VideoPlayer.broadcastEvent("mediachange", event)});
event.player.addEventListener("mediumchange", function(event){VideoPlayer.broadcastEvent("mediumchange", event)});
event.player.addEventListener("mediaPlayerElementEvent", function(event){VideoPlayer.broadcastEvent("playerelementevent", event)});
event.player.addEventListener("play", function(event){VideoPlayer.broadcastEvent("play", event)});
event.player.addEventListener("started", function(event){VideoPlayer.broadcastEvent("started", event)});
event.player.addEventListener("pause", function(event){VideoPlayer.broadcastEvent("paused", event)});
event.player.addEventListener("mediaPlayerResumeOrPausePlayback", function(event){VideoPlayer.broadcastEvent("pauseplayback", event)});
event.player.addEventListener("ended", function(event){VideoPlayer.broadcastEvent("ended", event)});
event.player.addEventListener("seeked", function(event){VideoPlayer.broadcastEvent("seeked", event)});
event.player.addEventListener("canplaythrough", function(event){VideoPlayer.broadcastEvent("canplaythrough", event)});
event.player.addEventListener("timeupdate", function(event){VideoPlayer.broadcastEvent("timeupdate", event)});
event.player.addEventListener("fullscreenchange", function(event){VideoPlayer.broadcastEvent("fullscreenchange", event)});
event.player.addEventListener("enterFullScreen", function(event){VideoPlayer.broadcastEvent("enterfullscreen", event)});
event.player.addEventListener("volumechange", function(event){VideoPlayer.broadcastEvent("volume_changed", event)});
if(event.player.ads!=null){
event.player.ads.addEventListener("started", function(event){abcn_ui.Helpers.video.globalAdStartedHandler(event);VideoPlayer.broadcastEvent("ad_started", event)});
event.player.ads.addEventListener("ended", function(event){abcn_ui.Helpers.video.globalAdEndedHandler(event);VideoPlayer.broadcastEvent("ad_ended", event)});
event.player.ads.addEventListener("companion", function(event){VideoPlayer.broadcastEvent("companion", event)});
}
if (event.player.share != null){
event.player.share.addEventListener("share", function(event){VideoPlayer.broadcastEvent("share", event)});
}
if (event.player.autoadvance != null){
event.player.autoadvance.addEventListener("advance", function(event){VideoPlayer.broadcastEvent("advance")});
}
if (event.player.recommendations != null){
event.player.recommendations.addEventListener("selected", function(event){$rootScope.broadcastEvent("recommendation")});
}
},
sharePlayerHandler : function(event){
event.player.mute();
event.player.pause();
event.player.captioning.setHidden(true);
event.player.addEventListener("play", function(event){VideoPlayer.broadcastEvent("playSharePlayer", event)});
//fire sitewide ready handler
abcn_ui.Helpers.video.globalReadyHandler(event);
},
previewReadyHandler : function(event){
event.player.mute();
event.player.setAutoplay(true);
event.player.captioning.setHidden(true);
$("#" + event.player.getContainer().id).parents("li").removeClass("preload");
$("#liveCarousel").jcarousel('reload');
//fire sitewide ready handler
abcn_ui.Helpers.video.globalReadyHandler(event);
},
broadcastEvent : function(eventName, eventData){
$rootScope.$broadcast(eventName, eventData);
},
play : function(player, id){
player.setAutoplay(true);
var feedUrl = feedUrlBase + "/video/itemfeed?id=" + id;
if(feedUrl != player.feed.getURL()){
player.setAutoplay(true);
player.feed.setURL(feedUrl);
}
player.play();
},
doPlay : function(player){
player.play();
},
randomRefreshTimeout: function (_maxDuration) {
var maxDuration = _maxDuration || 30;
return Math.ceil(Math.random() * maxDuration)
},
seedPlayer : function(player, id, format){
var formatParam = "";
if(typeof format != "undefined"){
formatParam = "&format=" + format;
}
var feedUrl = feedUrlBase + "/video/itemfeed?id=" + id + formatParam;
player.feed.setURL(feedUrl);
},
share : function(player, params, target){
player.pause();
//setup metadata
$("#video-share .title").html(player.evaluateBindings("#{media.title}"));
$("#video-share .description").html(player.evaluateBindings("#{media.description}"));
$("#video-share .share-thumb img").attr('src', player.evaluateBindings("#{media.metadata.thumb}"));
//For Bootstarp override
if(tq.section == 'live'){
$("a.button").css({height:"42px", width: "93px"});
$(".video_dialog div.top").css({height:"53px", padding:"10px 20px", font:'600 18px "proxima-nova" arial', });
$("#video-share span.label").css({"font-size":"18px", "top": "12px"});
$(".video_dialog .top .close").css("opacity","1");
$(".mid div.label").css({"font-size":"12px", "font-weight": "400"});
$(".video_dialog .embedcontainer textarea").css("color","#000")
}
initClipBoard = function(){
zclip_initialized = true;
$("#copy-button").zclip({
path: "/assets/flash/ZeroClipboard.swf",
copy: function(){
return $(this).prev().val();
},
afterCopy:function(){
alert("Copied to clipboard")
}
});
}
var embedStrLinks = $("#share-links").html();
$("#video-share #embedcode").val("
" + embedStrLinks)
$("#video-share .sharelink").each(function(){
$(this).off("click");
if($(this).attr("id") == "embed"){
$(this).on("click", function(){
$('.embedcontainer').slideDown(function(){
//initialize clipboard
if(typeof zclip_initialized == "undefined"){
initClipBoard();
}
});
});
}else{
$(this).on("click", function(){
var shareUrl = params.data.link;
switch ($(this).attr("id")){
case "facebook" :
shareUrl = (shareUrl.indexOf("?") == -1) ? shareUrl + "?cid=share_facebook_widget" : shareUrl + "&cid=share_facebook_widget";
break;
case "twitter" :
shareUrl = (shareUrl.indexOf("?") == -1) ? shareUrl + "?cid=share_twitter_widget" : shareUrl + "&cid=share_twitter_widget";
break;
case "email" :
shareUrl = (shareUrl.indexOf("?") == -1) ? shareUrl + "?cid=share_addthis_widget" : shareUrl + "&cid=share_addthis_widget";
break;
default:
break;
}
var url = "http://api.addthis.com/oexchange/0.8/forward/"+this.id+"/offer?url="+shareUrl;
window.open(url);
return false;
});
}
});
$("#share_overlay").fadeIn(function(){
$("#video-share").removeClass("offpage");
//add event listener for close
$("#video-share .close").click(function(){
VideoPlayer.shareExit(player, "video-share");
});
});
},
shareExit : function(player, target){
$("#video-share").addClass("offpage");
$("#share_overlay").fadeOut();
player.play();
if(player.playerType == "flash"){
player.getMediaElement().setPlayerProperty("shareBtn", {state: "inactive"})
}
//detach click
$("#video-share .sharelink").each(function(){
$(this).off("click");
});
},
setParams : function(player, params){
try{
for(param in params){
if(params.hasOwnProperty(param)){
var paramObj = {}
paramObj[param] = params[param]
player.setParams(paramObj);
}
}
}catch(e){
}
},
toggleShareButton : function(player){
try{
if(player.playerType == "flash"){
if(!player.evaluateBindings("#{media.metadata.shareEnabled}")){
player.getMediaElement().setPlayerProperty("shareBtn", {"visible":false});
}else{
player.getMediaElement().setPlayerProperty("shareBtn", {"visible":true});
}
}
}catch(e){
}
},
isSafari : function(){
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
},
cleanPlugins : function (){
/**
* [cleanPlugins remove / disable extra plugins for preview player from defaults data(XML)]
* @return {[type]} [description]
*/
if(akamai.amp.AMP.defaults.loaded){
if(akamai.amp.AMP.defaults.data){
var defaults = akamai.amp.AMP.defaults.data;
defaults.comscore.enabled = false;
defaults.comscorestreamsense.enabled = false;
defaults.nielsen.enabled = false;
defaults.omniture.enabled = false;
defaults.mediaanalytics.enabled = false;
defaults.captioning.enabled = false;
}
}
}
}
return VideoPlayer;
}])
.factory('VideoUtils', ['$rootScope', '$http', function ($rootScope, $http) {
//Public API
return ({
getExtras : getExtras,
getOutbrainPlaylist : getOutbrainPlaylist,
getRelateds : getRelatedItems,
getTopics : getTopics,
getPlaylist : getPlaylist,
getQueryParam : getParam,
getDisqus : getDisqus,
resetDisqus : resetDisqus,
addScript : addScript,
getSectionMapping : getSectionMapping,
fireBeacon : fireBeacon,
readCookie : readCookie,
createCookie : createCookie,
getSWID : getSWID,
getAffiliate: getAffiliateCookie,
getSegValues : fwSeg,
omniPageView : omniturePageView
})
function getRelatedItems(id, callback){
var url = "/video/relateds?id="+id+"&type=extras";
$http.get(url).success(callback);
}
function getTopics(id, callback){
var url = "/video/relateds?id="+id+"&type=topics";
$http.get(url).success(callback);
}
function getPlaylist(id, callback){
var url = "/video/relateds?id="+id+"&type=playlist";
$http.get(url).success(callback);
}
function getDisqus(id, callback){
var url = "/widgets/disqus?id="+id+"&mode=ajax";
$http.get(url).success(callback);
}
function getSectionMapping(section){
var validSections = {
"us" : "/us",
"international" : "/international",
"politics": "/politics",
"entertainment" : "/entertainment",
"technology" : "/technology",
"health" : "/health",
"lifestyle" : "/lifestyle",
"business" : "/business",
"blotter" : "/blotter",
"gma" : "/gma",
"wn" : "/wn",
"wnn" : "/wn",
"wnt" : "/wn"
}
var sect = (typeof section != "undefined") ? section.toLowerCase() : "";
if(validSections.hasOwnProperty(sect)){
return validSections[sect]
}else{
return "/";
}
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function createCookie(name,value,days,domain) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
if(domain !=null && typeof domain != 'undefined'){
domain = "; domain=" + domain;
}
document.cookie = name+"="+value+expires+domain+"; path=/";
}
function getSWID() {
swidCookie = readCookie('SWID');
return swidCookie;
}
function getAffiliateCookie() {
adNumCookie = readCookie('adnum');
if((!adNumCookie)||(adNumCookie=='4undefined')){
adNum=1;
}else{
adNum=parseInt(adNumCookie.charAt(0));
adNum++;
}
createCookie('adnum',adNum);
affilCookie = readCookie('affilcookie');
affil = (affilCookie)?affilCookie:'none';
return affil;
}
function segScores(i) {
var o = {};
if (!i.indexOf("CBLM-001:")) {
i = i.substring(9);
var id, sc, e = 0,f = 0,h = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
for (var b = 0,a = i.length,l = a - (a % 4); b < l;) {
var m = h.indexOf(i.charAt(b++));
var k = h.indexOf(i.charAt(b++));
f |= (m << 2 | k >> 4) << (e++ ? 0 : 8);
f *= (e %= 6) && e - 2 ? 1 : 0;
var j = h.indexOf(i.charAt(b++));
if (j != 64) {
f |= ((k & 15) << 4 | j >> 2) << (e++ ? 0 : 8);
if (!(e - 2)) {
id = f;
}
f *= (e %= 6) && e - 2 ? 1 : 0
}
var g = h.indexOf(i.charAt(b++));
if (g != 64) {
f |= ((j & 3) << 6 | g) << (e++ ? 0 : 8);
if (!(e - 6)) {
o[id] = f;
}
f *= (e %= 6) && e - 2 ? 1 : 0
}
}
}
return o;
}
function fwSeg() {
fwCookieStr = "";
fwCookie = readCookie('CRBLM');
if (fwCookie != null) {
fwCookie = segScores(fwCookie);
fwCookieStr = "seg=";
for (var i in fwCookie) {
if (fwCookie[i] > 0) {
fwCookieStr = fwCookieStr + i + "&seg=";
}
}
if(fwCookieStr.charAt(fwCookieStr.length-1)=='='){//remove trailing seg key
fwCookieStr = fwCookieStr.substring(0, fwCookieStr.length-5);
}
}
return fwCookieStr;
}
function omniturePageView() {
if(typeof s_omni != "undefined"){
s_omni.pageName = "abcn:s1_video:playerindex";
s_omni.prop4 = "playerindex"; //content type
s_omni.prop1 = "abcn"; //site name
s_omni.channel = "abcn:video"; //level1
s_omni.hier1 = "abcn:video"; //directory structure
s_omni.t();
}
}
function subsectionOverride() {
if(typeof tq != "undefined"){
if(tq.aoStr) {
tq.aoArr = tq.aoStr.split('~');
if(tq.aoArr.length > 2){
fwUpdateKeyValues('subsection', 'override-'+tq.aoArr[2].toLowerCase());
}
} else if (tq.override) {
fwUpdateKeyValues('subsection', 'override-'+tq.subsection);
}
}
}
//Public methods
function getExtras(id, callback, error){
var request = $http({
method: "get",
url: "/video/relateds?id="+id+"&type=relateds",
responseType : "json",
params: {
action: "get"
}
});
return( request.then( handleSuccess, handleError ) );
}
function getOutbrainPlaylist(link, callback){
var request_data = {
permalink: link,
widgetId: "VR_2",
installationKey: "ABC1AQLDOENO226MQH0B74C"
}
OBR.extern.callRecs(request_data, callback);
}
function resetDisqus(newIdentifier, newUrl, newTitle, newLanguage){
if(typeof DISQUS != "undefined"){
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = newIdentifier;
this.page.url = newUrl;
this.page.title = newTitle;
this.language = newLanguage;
}
});
}
}
function getParam(name) {
var start=location.search.indexOf("?"+name+"=");
if (start<0) start=location.search.indexOf("&"+name+"=");
if (start<0) return '';
start += name.length+2;
var end=location.search.indexOf("&",start)-1;
if (end<0) end=location.search.length;
var result='';
for(var i=start;i<=end;i++) {
var c=location.search.charAt(i);
result=result+(c=='+'?' ':c);
}
return unescape(result);
}
function fireBeacon(url) {
var beaconImg;
beaconImg = document.getElementById("beaconId");
if (!(beaconImg != null)) {
beaconImg = document.createElement("img");
beaconImg.setAttribute("id", "beaconId");
beaconImg.setAttribute("height", 0);
beaconImg.setAttribute("width", 0);
document.body.appendChild(beaconImg);
beaconImg.style.display = "none";
}
beaconImg.setAttribute("src", url);
return beaconImg;
}
function addScript(filepath, callback) {
if (filepath) {
var fileref = document.createElement('script');
var done = false;
var head = document.getElementsByTagName("head")[0];
fileref.onload = fileref.onreadystatechange = function () {
if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
done = true;
callback();
// Handle memory leak in IE
fileref.onload = fileref.onreadystatechange = null;
if (head && fileref.parentNode) {
head.removeChild(fileref);
}
}
};
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", filepath);
head.appendChild(fileref);
}
}
//Private Methods
function handleError(response){
if (!angular.isObject( response.data ) || ! response.data.message) {
return( $q.reject( "An unknown error occurred." ) );
}
// Otherwise, use expected error message.
return( $q.reject( response.data.message ) );
}
function handleSuccess(response){
return (response.data);
}
}])
//directives
.directive("abcnPlayer", ["VideoPlayer", "VideoUtils", function(VideoPlayer, VideoUtils){
return {
restrict : 'C',
replace : true,
scope : true,
template : function (element, attrs){
var playerClass = (typeof attrs.playerclass != "undefined") ? attrs.playerclass : "";
if(VideoPlayer.isSafari()){
if(attrs.mediatype != "akamai live stream"){
attrs.playbackmode = "html";
}
}
return '
';
},
link : function($scope, element, attrs){
var targetdiv = attrs.playerid;
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
attrs.controls = "none";
attrs.react_controls = true;
akamai.amp.AutoplayThreshold.init().then(function(threshold) {
attrs.autoplayPolicy = threshold;
var muted = (threshold === "muted" || threshold === "mutedinline") ? true: false;
attrs.muted = muted;
var config_overrides = abcn_ui.Helpers.video.configOverrides(attrs);
if(fullscreenAPI.isSupported()){
config_overrides.fullscreen = {mode : "external"};
}else{
try{
if(config_overrides.hasOwnProperty("fullscreen")){
delete config_overrides.fullscreen["mode"];
}
}catch(e){
//do nothing
}
}
// akamai.amp.AMP.loadDefaults(attrs.playerversion+"/amp.premier/amp.premier.default.json?stonewood=0&sec=1", function () {
// amp = akamai.amp.AMP.create(targetdiv, config_overrides, VideoPlayer.readyHandler);
// $("#"+targetdiv).append('');
// });
akamai.amp.AMP.requestJson(attrs.playerversion+"/amp.premier/amp.premier.default.json?stonewood=0&sec=1&site=abcn")
.then(function (config) {
// override page specific values
var mergedConfig = window.akamai.amp.Utils.override(config, config_overrides, true);
amp = akamai.amp.AMP.create(targetdiv, mergedConfig, VideoPlayer.readyHandler);
$("#"+targetdiv).append('')
})
.catch(function (error) {
console.log("Could not load player config", event.error);
});
});
}
}
}])
.directive("abcnSharePlayer", ["VideoPlayer", function(VideoPlayer){
return {
restrict : 'C',
replace : true,
scope : true,
template : function (element, attrs){
return ''
},
link : function(scope, element, attrs){
var previewPlaybackMode = "html-auto";
var videoFormat = (previewPlaybackMode == "html" || previewPlaybackMode == "html-auto") ? "m3u8" : "f4m_low";
var playerSettings = {
"autostart" : "true",
"clipid" : attrs.clipid,
"controls" : "none",
"volume" : 0,
"ads" : "false",
"chartbeat" : "false",
"omniture" : "false",
"playoverlay" : "false",
"namespace" : "svp",
"comscore" : "false",
"video_format" : videoFormat,
"playbackmode" : previewPlaybackMode
}
scope.$on('playSharePlayer', function(event, eventData) {
});
scope.$on('ready', function(event, eventData) {
//VideoPlayer.cleanPlugins();
//
setTimeout(function(){
sharePlayer = akamai.amp.AMP.create("svp", abcn_ui.Helpers.video.configOverrides(playerSettings), VideoPlayer.sharePlayerHandler);
}, 1000
)
});
}
}
}])
.directive("abcnShare", ["VideoPlayer", function(VideoPlayer){
return {
restrict : 'C',
replace : true,
scope : true,
template : function (element, attrs){
var scroller = (attrs.scroller == 'false') ? false : true;
var markup = ' \
\
Share \
\
'
if(typeof attrs.clipid != "undefined"){
markup = markup + '
'
}
markup = markup + '
\
';
if(scroller){
markup = markup + '
';
}
markup = markup + '
\
\
\
\
'
return markup;
},
link : function(scope, element, attrs){
}
}
}])
.directive("abcnCarousel", function(){
return {
restrict: 'A',
scope : true,
link : function(scope, element, attrs){
var itemsperpage = (typeof attrs.itemperpage != "undefined") ? attrs.itemperpage : 10;
var wrapsetting = (typeof attrs.wrap != "undefined") ? attrs.wrap : null;
if(attrs.srctype == "js"){
scope.$on('carouselLastItem', function(event){
//if(typeof jcarousel != "undefined"){
element.jcarousel({
vertical: false,
scroll: 1,
wrap: wrapsetting
});
$(element).prev()
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
})
.jcarouselControl({
target: '-='+attrs.itemperpage
});
$(element).next()
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
$(".upnext_overlay").show();
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
$(".upnext_overlay").hide();
})
.jcarouselControl({
target: '+='+attrs.itemperpage
});
//}
});
}else{
element.jcarousel({
vertical: false,
wrap: wrapsetting
});
$(element).prev()
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
})
.jcarouselControl({
target: '-='+attrs.itemperpage
});
$(element).next()
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
$(".upnext_overlay").show(); //TODO: make this specific
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
$(".upnext_overlay").hide(); //TODO: make this specific
})
.jcarouselControl({
target: '+='+attrs.itemperpage
});
}
}
}
})
.directive("carouselRepeatDirective", function(){
return {
restrict : "A",
scope : false,
link : function(scope, element, attrs){
if (scope.$last) {
scope.$emit('carouselLastItem');
}
}
}
})
.directive("remindme", function(){
return {
restrict : "C",
link: function(scope, element, attrs) {
element.bind('click', function() {
scope.calEventData = JSON.parse(element.next().html());
//element.parent().children().removeClass('clicked');
//element.addClass('clicked');
})
},
}
})
//controllers
.controller('vpCtrl', ['$scope', '$rootScope', '$window', '$timeout', '$interval', 'VideoPlayer', 'VideoUtils', function($scope, $rootScope, $window, $timeout, $interval, VideoPlayer, VideoUtils){
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//"
+ window.location.hostname
+ (window.location.port ? ':' + window.location.port: '');
}
$scope.parseObjectID = "";
$scope.currentVideo = null;
$scope.currentVideoIdx = -1;
$scope.nextVideoIdx = null;
$scope.videoId = null;
$scope.showUpNext = false;
$scope.timerStarted = false;
$scope.playlist = [];
$scope.playlistIds = [];
$scope.extras = [];
$scope.ob_playlist = [];
$scope.showComments = true;
$scope.showExtras = false;
$scope.showRelated = false;
$scope.showTranscript = false;
$scope.playlistActive = false;
$scope.videoDuration = "";
$scope.sharePos = 0;
$scope.isNewClip = false;
$scope.isFullScreen = false;
$scope.initialPlay = true;
$scope.isManualPlay = false;
$scope.outbrainMode = false;
$scope.fromPlaylist = false;
$scope.scrollAndRoll = function(){
$("html, body").animate({ scrollTop: 0 }, "300", function(){
amp.play()
return false;
})
};
$scope.getNextVideo = function(id){
var currVideo = id.toString();
if($scope.playlistIds != "undefined"){
if($scope.playlistIds.indexOf(currVideo) > -1){
var nextId = $scope.playlistIds.indexOf(currVideo) + 1;
if(nextId < $scope.playlistIds.length){
$scope.nextVideoIdx = nextId;
}else{
$scope.nextVideoIdx = 0;
}
}else{
$scope.nextVideoIdx = 0;
}
}
$scope.nextVideo = $scope.playlist[$scope.nextVideoIdx];
}
$scope.setCurrentVideo = function(id){
var currVideo = id.toString();
if($scope.playlistIds != "undefined"){
if($scope.playlistIds.indexOf(currVideo) > -1){
var newIdx = $scope.playlistIds.indexOf(currVideo);
if(newIdx < $scope.playlistIds.length){
$scope.currentVideoIdx = newIdx;
}else{
$scope.currentVideoIdx = 0;
}
}else{
$scope.currentVideoIdx = 0;
}
}
$scope.currentVideo = $scope.playlist[$scope.currentVideoIdx];
}
$scope.getOutbrainVideos = function (){
var permalink = "http://abcnews.go.com" + $scope.currentVideo.url
VideoUtils.getOutbrainPlaylist(permalink,
function(json){
$scope.playlistIds = [];
$scope.playlist = $scope.parseOutbrainPlaylist(json);
angular.forEach($scope.playlist, function(value, key){
$scope.playlistIds.push(parseInt(value.id))
});
$scope.getNextVideo($scope.videoId);
$scope.currentVideoIdx = $scope.playlistIds.indexOf($scope.videoId);
}
);
}
$scope.parseOutbrainPlaylist = function(json){
var opl = [];
for (var i = 0; i < json.doc.length; i++) {
try{
var doc = json.doc[i];
var item = {
"id" : doc.video.id,
"title" : doc.content,
"duration" : _player.formatDuration(doc.video.duration),
"date" : doc.publish_date,
"description" : doc.video.description.content,
"image" : doc.thumbnail.url,
"mediaType" : "Default",
"relatedStory" : "",
"idx" : i,
"url" : doc.orig_url.replace("http://abcnews.go.com", ""),
"ob_url" : doc.url
}
opl.push(item);
}catch(e){
//do nothing
}
}
return opl;
}
$scope.trackOutbrainVideo = function(){
var reqData = {
link: $scope.currentVideo.ob_url
};
var callBackFuncObj = function(json){
//do nothing
};
OBR.extern.callClick(reqData, callBackFuncObj);
}
var init = function(){
$scope.currentVideo = JSON.parse($("#hidden").html());
$scope.videoId = $scope.currentVideo.id;
$scope.videoTitle = $scope.currentVideo.title;
if($("#_transcripts ._text").html().length == 1){
$(".tab_transcript").hide();
}
if($("#_extras #related_extras li").length > 0){
$(".tab_extras").show();
}else{
$(".tab_extras").hide();
}
if($("#_extras #related_extras li").length > 0){
$(".tab_extras").show();
}else{
$(".tab_extras").hide();
}
if($("#_relateds #related_carousel li").length > 0){
$(".tab_relateds").show();
}else{
$(".tab_relateds").hide();
}
if($scope.extras.length > 0){
$scope.showExtras = true;
}
//register the waypoint
if(typeof $.waypoints != "undefined"){
$('#waypoint-marker').waypoint({
offset: 20,
handler : function(dir){
if(dir == "down"){
if($scope.showComments || $scope.showTranscript){
if(!_player.isAdInProgress){
_player.minimize();
$scope.isPlayerStuck = true;
}
}
}else if(dir == "up"){
_player.maximize();
$scope.isPlayerStuck = false;
}
}
});
$('#waypoint-marker').waypoint('disable');
}
}
$scope.close = function(){
$scope.showUpNext = false;
$scope.cancelUpNextTimer();
}
var _player = {};
_player.isPaused = false;
_player.shouldPlay = true;
_player.height = $("#videoplayer").height();
_player.width = $("#videoplayer").width();
_player.pausedFromShare = false;
_player.pausedFromMiniPlayer = false;
_player.endedFromMiniPlayer = false;
_player.noPauseScreen = false;
_player.isHelpScreenActive = false;
_player.isAdInProgress = false;
_player.closeHelpScreen = function(){
$("#help").removeClass("active");
$("#help_overlay, #help_page_overlay").fadeOut(200);
}
_player.launchPauseScreen = function(){
$("#pause_overlay, #pause_overlay_meta").fadeIn();
$scope.scrollCarousel("relatedPausedCarousel", $scope.currentVideoIdx);
};
_player.removePauseScreen = function(){
$("#pause_overlay, #pause_overlay_meta").fadeOut();
};
$scope.scrollCarousel = function(carouselId, idx){
var carousel_to_scroll = $("#"+carouselId);
carousel_to_scroll.jcarousel('scroll', idx);
};
$scope.$watch('showRelated', function (val){
if(val === true && $scope.currentVideoIdx > -1) {
setTimeout(function(){
$("#related_carousel").jcarousel("scroll", $scope.currentVideoIdx);
}, 200)
}
});
_player.minimize = function(){
_player.removePauseScreen();
if(_player.ctrlbarTimeout){
window.clearTimeout(_player.ctrlbarTimeout);
}
if(typeof amp != "undefined"){
try{
//amp.controls.setMode("none");
$(".amp-controls, .amp-progress").hide();
}catch(e){
//do nothing
}
}
$('#mini-player-panel').animate({width: '270px'}, 200, function(){
$("#player-placeholder").addClass("active");
$("#videoplayer").addClass("stuck");
$("._cliptitle").html($('#video_header h1, #_transcripts .title').html());
$("._clipcaption").html($('#video_header .overview').html())
});
};
_player.ctrlbarTimeout = null;
_player.maximize = function(){
$("#videoplayer").removeClass("stuck").css("margin-left", "");
$("#player-placeholder").removeClass("active");
$('#mini-player-panel').animate({width: '0'}, 200, function(){
$("._cliptitle, ._clipcaption, ._cliplabel").html("");
$("._cliplink, .mini-player-overlay").hide();
});
_player.ctrlbarTimeout = setTimeout(function(){
//amp.controls.setMode("persistent");
$(".amp-controls, .amp-progress").show();
}, 1000)
}
_player.updateMetaTag = function(tagname, tagvalue){
$('meta[name='+tagname+']').remove();
$('head').append( '' );
}
_player.updateVideoInfo = function(){
if (Modernizr.history) {
var newURL = $scope.currentVideo.url;
window.parent.history.replaceState(null, "", newURL);
document.title = $scope.currentVideo.title + " Video - ABC News";
_player.updateMetaTag("description", $scope.currentVideo.description);
}
$('#video_header h1').html($scope.currentVideo.title);
$('#video_header .overview').html($scope.currentVideo.description);
$('#video_header .dateTime .date').html($scope.currentVideo.date);
$('#video_header .dateTime .duration').html($scope.currentVideo.duration);
if($scope.currentVideo.relatedStory != ""){
$('.fullstory').html('Read Full Story');
}else{
$('.fullstory').html('');
}
//reset tabs modules
if($scope.currentVideo.transcript != ""){
$(".tab_transcript, #_transcripts").show();
$("#_transcripts ._title span").html($scope.currentVideo.title);
$("#_transcripts ._text").html($scope.currentVideo.transcript);
}else{
$(".tab_transcript, #_transcripts").hide();
}
// blue kai
if(window.bkInit){
window.bkInit();
}
VideoUtils.resetDisqus($scope.currentVideo.id, $scope.currentVideo.title, $scope.currentVideo.link, "en");
VideoUtils.getRelateds($scope.currentVideo.id, function(results) {
$scope.extras = results;
if($scope.extras.length == 0){
$(".tab_extras, #_extras").hide();
$(".upnext_overlay").hide()
}else{
$(".tab_extras, #_extras").show();
if($scope.extras.length == 1){
$(".upnext_overlay").hide()
}else{
$(".upnext_overlay").show()
}
var extras_carousel = $("#_extras .jcarousel");
extras_carousel.jcarousel('scroll', 0);
var extras_carousel_items = extras_carousel.jcarousel('items');
angular.forEach(extras_carousel_items, function(value, key){
if(key > 0){
value.remove();
}
})
//extras_carousel.jcarousel('reload');
angular.forEach($scope.extras, function(value, key){
var relIcon = (value.type == "Video")?'':'';
var relImage = '';
var relDescription = ''+value.description+'
';
if(key == 0){
$('#_extras .jcarousel li:eq(0)')
.html(relImage+''+relDescription);
}else{
$("#related_extras ul").append(''+relImage+''+relDescription+'');
}
})
extras_carousel.jcarousel("reload");
}
});
VideoUtils.getTopics($scope.currentVideo.id, function(results) {
$(".topics").html(results.topics);
});
if($scope.outbrainMode){
$scope.getOutbrainVideos();
}
}
_player.scrollToTop = function(){
$("html, body").animate({ scrollTop: 0 }, "300", function(){
return false;
})
}
_player.formatDuration = function(d) {
d = Number(d);
var m = Math.floor(d % 3600 / 60);
var s = Math.floor(d % 3600 % 60);
return ((m > 0 ? (m < 10 ? "0" : "") + m + ":" : "0:") + (s < 10 ? "0" : "") + s); }
init();
//player events functions
var readyHandler = $scope.$on('ready', function() {
try{
amp.setAutoplay(true);
amp.captioning.setHidden(true);
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("playlistBtn", {visible:false});
}
abcn_ui.Helpers.video.togglePlayerLoader(false, amp)
}catch(e){
}
abcn_ui.Helpers.video.setFWDefaultParams(amp);
VideoPlayer.setParams(amp, {
"adUnitPath" : abcn_ui.Helpers.video.getAdUnitPath($scope.currentVideo.section, "abcnews.com"),
"siteSectionId" : "nws_vididx_other",
"pageType" :"videoindex",
"referer" : "http://abcnews.go.com"+$scope.currentVideo.url,
"show" : "",
"playerLocation" : "player|videoindex",
"eVar29":abcn_ui.Helpers.video.getPageName(),
"eVar62" : "autoplay",
"videoPlayType" : "auto",
"videoViewEvent" : "event1"});
setTimeout(function(){
if(typeof $window.outbrainPlaylist != 'undefined'){
$scope.outbrainMode = $window.outbrainPlaylist;
}
if($scope.outbrainMode){
$scope.getOutbrainVideos();
$("#_relateds").find(".jcarousel-wrapper").eq(0).hide();
}else{
VideoUtils.getPlaylist($scope.videoId, function(results) {
$scope.playlist = results;
angular.forEach(results, function(value, key){
$scope.playlistIds.push(value.id)
});
$scope.getNextVideo($scope.videoId);
$scope.currentVideoIdx = $scope.playlistIds.indexOf($scope.videoId);
});
}
},200);
VideoUtils.getDisqus($scope.videoId, function(results){
$("#_comments").html(results);
});
});
var canplayHandler = $scope.$on('can_play', function(){
abcn_ui.Helpers.video.setPlayerParams(amp, {
"eVar32" : "#{media.metadata.omniture.eVar32}"
});
});
var canplaythroughHandler = $scope.$on('canplaythrough', function(){
var startPos = VideoUtils.getQueryParam('ts');
if(startPos != "undefined" && startPos != ""){
amp.setCurrentTime(startPos)
}
$scope.isNewClip = false;
})
var playHandler = $scope.$on('play', function() {
VideoPlayer.toggleShareButton(amp);
$scope.videoDuration = parseInt(amp.getDuration(), 10); // 20;
$scope.videoId = amp.evaluateBindings("#{media.guid}");
if($scope.isNewClip){
VideoUtils.omniPageView();
$scope.initialPlay = true;
if($scope.outbrainMode){
$scope.trackOutbrainVideo();
}
}
if ($scope.initialPlay) {
$scope.initialPlay = false;
}
_player.isPaused = false;
_player.endedFromMiniPlayer = false;
_player.pausedFromMiniPlayer = false;
_player.pausedFromShare = false;
_player.removePauseScreen();
if(typeof $.waypoints != "undefined"){
$('#waypoint-marker').waypoint('enable');
}
$("#video_header .more, #help").fadeIn(200);
var s_omni_override = {
prop4 : 'video',
prop5 : '',
prop15 : '',
eVar2 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar2}") : "",
eVar20 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar20}") : "",
eVar29 : (typeof amp != "undefined") ? amp.evaluateBindings("#{eVar29}") : "",
eVar32 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar32}") : "",
eVar45 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar45}") : "",
prop54 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.prop54}") : "",
channel : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.channel}") : "",
prop2: abcn_ui.Helpers.video.getSWID()
}
if(typeof bkInit != "undefined"){
window.bkInit(s_omni_override);
}
});
var endedHandler = $scope.$on('ended', function(data){
// to determine if this a playlist or manual click on related
$scope.isManualPlay = false;
//retrieve the next video and its metadata
upnexttimeout = "undefined"; //reset the timer
$scope.$apply(function(){
$scope.showUpNext = false;
$scope.timerStarted = false;
$scope.cancelTimer(upnexttimeout);
});
//VideoPlayer.seedPlayer(amp, $scope.videoId)
if($scope.currentVideo.mediaType == "rapt"){
//do nothing
}else{
if($scope.playlist.length > 0){
$scope.isNewClip = true;
$scope.getNextVideo ($scope.currentVideo.id);
$scope.currentVideoIdx = $scope.playlistIds.indexOf($scope.nextVideo.id);
$scope.setCurrentVideo($scope.nextVideo.id);
$("#_relcaption" + ($scope.currentVideoIdx - 1)).hide();
_player.updateVideoInfo();
$.event.trigger({
type: "abcn.video.loadnextclip",
id: $scope.currentVideo.id,
playlist_length : $scope.playlist.length
});
if($scope.isPlayerStuck){
_player.endedFromMiniPlayer = true;
$("._cliptitle").html($scope.nextVideo.title);
$("._clipcaption").html($scope.nextVideo.description);
$("._cliplabel").html("Up Next:");
$("._cliplink, .mini-player-overlay").show();
}else{
_player.shouldPlay = true;
}
VideoPlayer.seedPlayer(amp, $scope.nextVideo.id);
$scope.getNextVideo ($scope.nextVideo.id);
$scope.fromPlaylist = true;
}else{
amp.play();
}
VideoPlayer.setParams(amp, {"videoPlayType" : "continuous"});
}
});
var pauseplaybackHandler = $scope.$on('pauseplayback', function(event, eventData){
$scope.cancelUpNextTimer();
});
var shareHandler = $scope.$on('share', function(event, eventData) {
if(!fullscreenAPI.isSupported()){
amp.exitFullScreen()
}
_player.pausedFromShare = true;
VideoPlayer.seedPlayer(sharePlayer, $scope.videoId, 'mp4_low');
amp.pause();
//setup metadata
$("#video-share .title").html(amp.evaluateBindings("#{media.title}"));
$("#video-share .description").html(amp.evaluateBindings("#{media.description}"));
$("#video-share .share-thumb img").attr('src', amp.evaluateBindings("#{media.metadata.thumb}"));
var embedStrLinks = $("#share-links").html();
var share_url = eventData.data.embed.url + "?id=" + amp.evaluateBindings('#{media.guid}');
if($scope.sharePos != 0){
share_url = share_url + "&ts=" + $scope.sharePos
}
$("#video-share #embedcode").val("
" + embedStrLinks)
$(".slider").slider({
max : $scope.videoDuration,
create : function(event, ui){
$('.ui-slider-handle').html('');
},
slide: function(event, ui) {
$("#svp").removeClass("offpage");
$scope.$apply(function(){
$scope.sharePos = ui.value;
$("#video-share #embedcode").val("
" + embedStrLinks)
})
sharePlayer.setCurrentTime(ui.value);
sharePlayer.pause();
sharePlayer.setAutoplay(false);
var totalSec = ui.value;
var minutes = parseInt( totalSec / 60 ) % 60;
var seconds = totalSec % 60;
var result = (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
$('.ui-slider-handle').html('');
}
});
initClipBoard = function(){
zclip_initialized = true;
$("#copy-button").zclip({
path: "/assets/flash/ZeroClipboard.swf",
copy: function(){
return $(this).prev().val();
},
afterCopy:function(){
$("#copy-button").html("Copied to clipboard").addClass("copied");
}
});
}
$("#video-share .sharelink").each(function(){
if($(this).attr("id") == "embed"){
$(this).on("click", function(){
$('.embedcontainer').slideDown(function(){
//initialize clipboard
if(typeof zclip_initialized == "undefined"){
initClipBoard();
}
});
});
}else{
$(this).on("click", function(){
var shareUrl = eventData.data.link;
switch ($(this).attr("id")){
case "facebook" :
shareUrl = (shareUrl.indexOf("?") == -1) ? shareUrl + "?cid=share_facebook_widget" : shareUrl + "&cid=share_facebook_widget";
break;
case "twitter" :
shareUrl = (shareUrl.indexOf("?") == -1) ? shareUrl + "?cid=share_twitter_widget" : shareUrl + "&cid=share_twitter_widget";
break;
case "email" :
shareUrl = (shareUrl.indexOf("?") == -1) ? shareUrl + "?cid=share_addthis_widget" : shareUrl + "&cid=share_addthis_widget";
break;
default:
break;
}
var url = "http://api.addthis.com/oexchange/0.8/forward/"+this.id+"/offer?url="+shareUrl;
if($scope.sharePos != 0){
url = url + "?ts=" + $scope.sharePos
}
window.open(url);
return false;
});
}
});
$("#share_overlay").fadeIn(function(){
$("#video-share").removeClass("offpage");
//add event listener for close
$("#video-share .close").click(function(){
VideoPlayer.shareExit(amp, "video-share");
});
});
});
var pausedHandler = $scope.$on('paused', function(data) {
if($scope.isPlayerStuck){
_player.pausedFromMiniPlayer = true;
_player.isPaused = true;
}else{
$('#waypoint-marker').waypoint('disable');
_player.isPaused = true;
$scope.timerStarted = false;
$scope.cancelTimer(upnexttimeout);
}
// if(!_player.pausedFromShare && !_player.pausedFromMiniPlayer && !_player.noPauseScreen) {
// _player.launchPauseScreen();
// }
});
var ad_startedHandler = $scope.$on('ad_started', function() {
// toggle ad on
_player.isAdInProgress = true;
$scope.checkAd();
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("fullscreenBtn", {visible:false});
}
if($('#_fw_container_300x250slot').html() != ""){
$scope.stopCheckAd();
$(".video_container .adslug").fadeIn(200);
}
if(!$scope.isPlayerStuck && !$scope.isFullScreen){
if(typeof waypoint != "undefined"){
$('#waypoint-marker').waypoint('disable');
}
$("#video_header .more, #help").fadeOut(200);
$("#videoplayer, #videoplayer .akamai-video").animate({
width: "640",
height: "424"
}, 1000, function(){
$(".video_container #bannerad").fadeIn();
});
}
});
var started_handler = $scope.$on('started', function(){
//abcn_ui.Helpers.video.fireBlueKaiBeacon(amp);
if($scope.currentVideo.mediaType.toLowerCase() == "rapt"){
amp.controls.setMode("none");
}
if($scope.fromPlaylist == false){
abcn_ui.Helpers.video.fireOutbrainBeacon();
}
})
var adChecker;
$scope.checkAd = function(){
if(angular.isDefined(adChecker)) return;
adChecker = $interval(function() {
if($('#_fw_container_300x250slot').html() != ""){
$scope.stopCheckAd();
$(".video_container .adslug").fadeIn(200);
}
}, 500)
}
$scope.stopCheckAd=function(){
if (angular.isDefined(adChecker)) {
$interval.cancel(adChecker);
adChecker = undefined;
}
};
var ad_endedHandler = $scope.$on('ad_ended', function() {
_player.isAdInProgress = false;
$scope.stopCheckAd();
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("fullscreenBtn", {visible:true});
}
$("#video_header .more, #help").fadeIn(200);
$(".video_container .adslug").hide();
$(".video_container #bannerad").fadeOut();
if(!$scope.isPlayerStuck && !$scope.isFullScreen){
$('#_fw_container_300x250slot').html('');
$("#videoplayer, #videoplayer .akamai-video").animate({
width: _player.width,
height: _player.height
}, 800, function(){
$("#videoplayer, #videoplayer .akamai-video").attr("style", "");
if(typeof waypoint != "undefined"){
$('#waypoint-marker').waypoint('enable');
}
});
}
});
//fullscreenchange
var fullscreendHandler = $scope.$on('fullscreenchange', function(data, eventData){
// if(VideoPlayer.isSafari()){
if(fullscreenAPI.isSupported()){
if (fullscreenAPI.isFullScreen()) {
fullscreenAPI.CancelFullScreen();
$("#video_container").removeClass("fullscreen");
$scope.$apply(function(){
$scope.isFullScreen = false;
$scope.showUpNext = false;
});
}
else {
$("#video_container").addClass("fullscreen");
$scope.$apply(function(){
$scope.isFullScreen = true;
});
var elem = document.getElementById('video_stage');
fullscreenAPI.RequestFullScreen(elem);
fullscreenAPI.Fullscreenchange(fullScreenOptions);
}
}
//}
})
var playerelementevent_handler = $scope.$on('playerelementevent', function(data, eventData) {
//handle the playlist button
if(eventData.data.element == "playlistBtn" && eventData.data.type == "click"){
$scope.playlistActive = !$scope.playlistActive;
if ($scope.playlistActive){
$scope.$apply(function(){
$scope.showUpNext = true;
});
}else{
$scope.$apply(function(){
$scope.showUpNext = false;
});
}
}
if(eventData.data.element == "fullscreenBtn" && eventData.data.type == "click"){
if(fullscreenAPI.isSupported()){
if (fullscreenAPI.isFullScreen()) {
fullscreenAPI.CancelFullScreen();
$("#video_container").removeClass("fullscreen");
$scope.$apply(function(){
$scope.isFullScreen = false;
$scope.showUpNext = false;
});
}
else {
$("#video_container").addClass("fullscreen");
$scope.$apply(function(){
$scope.isFullScreen = true;
});
var elem = document.getElementById('video_stage');
fullscreenAPI.RequestFullScreen(elem);
fullscreenAPI.Fullscreenchange(fullScreenOptions);
}
}
}
});
$scope.toggleFullscreenControls = function(){
$scope.isFullscreen = !$scope.isFullscreen;
if ($scope.isFullscreen){
//if(VideoPlayer.isSafari()){
$(amp.getContainer()).addClass("akamai-full-screen");
//}
}else{
fullscreenAPI.CancelFullScreen();
$("#video_container").removeClass("fullscreen");
//if(VideoPlayer.isSafari()){
$(amp.getContainer()).removeClass("akamai-full-screen");
//}
$scope.$apply(function(){
$scope.showUpNext = false;
$scope.isFullScreen = false;
});
}
}
fullScreenOptions = function(){
if (fullscreenAPI.isFullScreen()) {
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("playlistBtn", {visible:true});
}
$('#waypoint-marker').waypoint('disable');
}else {
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("playlistBtn", {visible:false});
amp.getMediaElement().setPlayerProperty("fullscreenBtn", {state:"active"});
//$('#waypoint-marker').waypoint('enable');
}
}
}
//timer vars
var upnexttimeout = "undefined";
var timeupdate = $scope.$on('timeupdate', function(event, eventData) {
if($scope.playlist.length == 0){
timeupdate();
}
if(eventData.player.getCurrentTime() > 0){
if($scope.currentVideo.mediaType != "Akamai Live Stream"){
var delta = eventData.player.getDuration() - eventData.player.getCurrentTime();
var threshold = 20;
if((delta != 0) && delta < 20){
$scope.showUpNext = true;
if(upnexttimeout == "undefined"){
$scope.runCounter(Math.round(delta))
}
}
}
}
});
$scope.runCounter = function(startCount){
$scope.timerStarted = true;
$scope.countdown = startCount;
upnexttimeout = $timeout($scope.onTimeout,1000);
}
$scope.onTimeout = function(){
if( _player.isPaused ) return;
$scope.countdown--;
if($scope.countdown == 1){
$scope.countdownlbl = "second";
}
if ($scope.countdown > 0) {
$scope.countdownlbl = "seconds";
upnexttimeout = $timeout($scope.onTimeout,1000);
}else {
$timeout.cancel(upnexttimeout);
$scope.showUpNext = false;
}
};
$scope.cancelTimer = function(timer){
if(timer){
$timeout.cancel(timer);
$scope.timerStarted = false;
}
}
$scope.cancelUpNextTimer = function(){
$scope.cancelTimer(upnexttimeout);
}
$scope.playVideo = function(id, event){
//amp.stop()
$.event.trigger({
type: "abcn.video.playvideo"
});
event.preventDefault();
$scope.setCurrentVideo(id);
VideoPlayer.seedPlayer(amp, id);
_player.updateVideoInfo();
_player.removePauseScreen();
$scope.getNextVideo(id);
$scope.isNewClip = true;
$scope.isPaused = false;
$scope.showUpNext = false;
$scope.isManualPlay = true;
$.event.trigger({
type: "abcn.video.loadnextclip",
id: $scope.currentVideo.id,
playlist_length : $scope.playlist.length
});
// blue kai
if(window.bkInit){
window.bkInit();
}
}
$scope.toggleDrawer = function(){
$(".video_meta_drawer").slideToggle("slow", function(){
$("#video_header .more").toggleClass( "moreActive" );
$("#pause_overlay").toggleClass("tall");
});
}
$scope.handlePlayer = function(){
if($scope.isPlayerStuck){
if($scope.showComments || $scope.showTranscript){
_player.minimize();
}else{
_player.maximize();
}
}
}
$scope.unPausePlayer = function(){
_player.removePauseScreen();
amp.play();
}
//unbind listeners
$rootScope.$on("$destroy", function(){
readyHandler();
canplaythroughHandler();
playHandler();
endedHandler();
pauseplaybackHandler();
shareHandler();
pausedHandler();
ad_startedHandler();
ad_endedHandler();
playerelementevent_handler();
amp.destroy();
});
//all jquery goes here
angular.element(document).ready(function () {
$('.jcarousel').hoverIntent({
over: function(){
var _relpos = $(this).attr("data-idx");
var iscurrent = (_relpos == $scope.currentVideoIdx)?true:false;
$(".shadow", this).fadeIn(200);
$(".icon", this).show();
if(!iscurrent){
$(this).prev().fadeIn(200);
$("#current", $(this).closest(".jcarousel")).hide();
}else{
$(this).siblings("#current").show();
}
if(window.cTimeout){
window.clearTimeout(window.cTimeout);
}
},
out : function(){
var el = this;
$('._relcaption:not(#current)').hide();
$(".icon", el).hide();
$(".shadow", el).hide();
window.cTimeout = setTimeout(function(){
$("#current", $(el).closest(".jcarousel")).show();
}, 500)
},
selector : "._relvideo"
});
if($(document).scrollTop() != 0){
_player.scrollToTop();
}
if(typeof $window.vrAjax != "undefined" && $window.vrAjax != "undefined"){
VideoUtils.omniPageView();
}
//exit fullscreen listeners
$(document).on({
'fullscreenchange': function()
{
$scope.toggleFullscreenControls();
},
'mozfullscreenchange': function()
{
$scope.toggleFullscreenControls();
},
'webkitfullscreenchange': function()
{
$scope.toggleFullscreenControls();
}
});
//$scope.hovered = false;
$("#closelightbox").click(function(){
if(typeof window.parent.vrOrigin != "undefined"){
window.parent.location = window.parent.vrOrigin;
}else{
//get the section of the video
var sec = VideoUtils.getSectionMapping($scope.currentVideo.section);
//console.log("______" + window.location.origin + sec)
window.parent.location = window.parent.location.origin + sec;
}
});
$("#help").click(function(){
_player.isHelpScreenActive = !_player.isHelpScreenActive;
if(_player.isHelpScreenActive){
_player.noPauseScreen = true;
$("#help_overlay, #help_page_overlay").fadeIn(200);
$("#help").addClass("active");
amp.pause()
}else{
_player.noPauseScreen = false;
_player.closeHelpScreen();
amp.play()
}
});
$("#help_page_overlay").click(function(){
_player.closeHelpScreen();
amp.play();
});
$(document).keyup(function(e) {
if (e.keyCode == 27) {
_player.closeHelpScreen();
amp.play();
}
});
});
}])
.controller('LiveCtrl', ['$scope', '$timeout', '$window', '$interval', '$http', 'VideoPlayer', 'VideoUtils', function($scope, $timeout, $window, $interval, $http, VideoPlayer, VideoUtils){
var baseurl = "";
$scope.playlist = JSON.parse($("#hidden").html());
$scope.promoVideoList = JSON.parse($("#promoHidden").text());
$scope.mainvideo = $scope.playlist[0];
if(/previews=false/.test(window.location)){
$scope.playlist = [];
}
if(/autoplay=false/.test(window.location)) {
$scope.disableAutoPlay = true;
}
$scope.playlistCached = $scope.playlist;
$scope.drawerCallout = "Minimize additional streams";
$scope.drawerActive = true;
$scope.isFullScreen = false;
$scope.mainPlayerIsReady = false;
players = [];
var lp = {};
lp.width = $(".videoplayerwrapper").width();
lp.height = $(".videoplayerwrapper").height();
lp.pausedFromShare = false;
lp.isHelpScreenActive = false;
lp.closeHelpScreen = function(){
$("#help").removeClass("active");
$("#help_overlay, #help_page_overlay").fadeOut(200);
}
lp.adComplete = false;
lp.seededbyVCR = false;
$scope.doSwap = function (pos){
//swap the location of the main video [0] with the clicked video [x]
try{
var newMainVideo = $scope.playlist[pos];
var videoFormat = "m3u8_low";
VideoPlayer.seedPlayer(amp, newMainVideo.id.toLowerCase());
//make sure the main video hasn't ended
if($scope.mainvideo.isStarted){
$scope.playlist[pos] = $scope.mainvideo;
createPlayers(pos, $scope.playlist[pos].id.toLowerCase())
}else{//remove out of date main video from the playlist and destroy player
$scope.playlist.splice(pos, 1)
seeder();
}
$scope.mainvideo = newMainVideo;
amp.setVolume("0.75");
$(".mainvideotitle").html($scope.mainvideo.hed);
$(".mainvideodesc").html($scope.mainvideo.description);
VideoPlayer.setParams(amp, {"videoPlayType" : "general click"}); // set videoPlayType to "general click'" as a new video was clicked
}catch(e){
//console.log('error', e)
//do nothing
}
}
var _useHlsJs = false;
var liveUrlMap;
$http.get("/video/hlspreview").success(
function(data){
liveUrlMap = data;
}
);
function seeder (){
var previewPlaybackMode = "html-auto";
var videoFormat = (previewPlaybackMode == "html-auto") ? "m3u8_low" : "f4m_low";
cleanPlugin = true;
angular.forEach($scope.playlist, function(value, idx){
if(idx > 0){
if(lp.seededbyVCR){
//just update the markup and seed the player
if(typeof players[idx-1] == "object"){
if(players[idx-1].evaluateBindings("#{media.guid}") != $scope.playlist[idx].id){
createPlayers(idx, $scope.playlist[pos].id.toLowerCase())
}
}else{
//create player
createPlayers (idx, value)
}
}else{
createPlayers (idx, value)
}
}
});
if($scope.playlistCached.length > $scope.playlist.length){
var itemsToRemove = $scope.playlistCached.length - $scope.playlist.length;
for(i = 0; i < itemsToRemove; i++){
players.pop();
}
}
}
function createPlayers (_idx, _value){
var idx = _idx || 0,
value = _value || {},
clipId = (typeof value === 'object') ? value.id : value,
url = 'https://a.abcnews.com/images/US/abc_news_default_2000x2000_update_16x9_384.jpg';
if (clipId) {
clipId = clipId.toLowerCase();
clipId = clipId.replace('abc_live', '');
clipId = parseInt(clipId);
url = 'https://keyframe-cdn.abcnews.com/streamprovider' + clipId + '.jpg';
}
$('#player-' + idx).html('');
}
$scope.$on('carouselLastItem', function(event){
//alert('carouselLastItem')
if(!lp.seededbyVCR){
seeder();
}
});
//player events functions
$scope.$on('ready', function(){
try{
amp.captioning.setHidden(true);//needed this bec by default CC is showing
amp.setAutoplay($scope.disableAutoPlay ? false : true);
amp.getMediaElement().setPlayerProperty("playlistBtn", {visible:false});
//amp.getMediaElement().setPlayerProperty("shareBtn", {"visible":false});
}catch(e){
}
abcn_ui.Helpers.video.setFWDefaultParams(amp);
VideoPlayer.setParams(amp, {
"adUnitPath" : abcn_ui.Helpers.video.getAdUnitPath("live", "abcnews.com"),
"siteSectionId" : "nws_live",
"pageType" :"liveevent",
"referer" : "http://abcnews.go.com/live",
"playerLocation" : "player|liveevent",
"eVar29": abcn_ui.Helpers.video.getPageName(),
"eVar62": "autoplay",
"videoPlayType" : "auto",
"noAd" : "t",
"videoViewEvent" : "event1"})
abcn_ui.Helpers.video.togglePlayerLoader(false, amp)
});
$scope.$on('can_play', function(){
VideoPlayer.setParams(amp, {
"eVar32" : "#{media.metadata.omniture.eVar32}"
});
});
$scope.$on('play', function(){
$("#video_stage .livebug, #help, .schedulebtn").fadeIn();
VideoPlayer.toggleShareButton(amp);
removePauseScreen();
lp.pausedFromShare = false;
});
$scope.$on('started', function(){
var s_omni_override = {
prop4 : 'video',
prop5 : '',
prop15 : '',
eVar2 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar2}") : "",
eVar20 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar20}") : "",
eVar29 : (typeof amp != "undefined") ? amp.evaluateBindings("#{eVar29}") : "",
eVar32 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar32}") : "",
eVar45 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.eVar45}") : "",
prop54 : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.prop54}") : "",
channel : (typeof amp != "undefined") ? amp.evaluateBindings("#{media.metadata.omniture.channel}") : "",
prop2: abcn_ui.Helpers.video.getSWID()
}
if(typeof bkInit != "undefined"){
window.bkInit(s_omni_override);
}
});
var adChecker;
$scope.checkAd = function(){
if(angular.isDefined(adChecker)) return;
adChecker = $interval(function() {
if($('#_fw_container_300x250slot').html() != ""){
$scope.stopCheckAd();
$(".videoplayerwrapper .adslug").fadeIn(200);
}
}, 500);
}
$scope.stopCheckAd=function(){
if (angular.isDefined(adChecker)) {
$interval.cancel(adChecker);
adChecker = undefined;
}
};
$scope.$on('ad_started', function() {
if(!lp.adComplete){
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("fullscreenBtn", {visible:false});
}
$("#video_header .more, #help, .schedulebtn").fadeOut(200);
$scope.checkAd()
if($('#_fw_container_300x250slot').html() != ""){
$scope.stopCheckAd();
$(".videoplayerwrapper .adslug").fadeIn(200);
}
$("#liveEvent #bannerad").fadeIn(200);
// $("#videoplayer, #liveEvent .mainvideobg img").animate({
// width: "640",
// height: "424"
// }, 1000, function(){
// $("#video_stage .livebug").fadeOut();
// });
}
});
//fullscreenchange
var fullscreendHandler = $scope.$on('fullscreenchange', function(data, eventData){
// if(VideoPlayer.isSafari()){
if(fullscreenAPI.isSupported()){
if (fullscreenAPI.isFullScreen()) {
fullscreenAPI.CancelFullScreen();
$(".bodycontainer").removeClass("fullscreen");
$(".drawer").removeClass("offpage");
$scope.showDrawer = true;
}
else {
$scope.$apply(function(){
$scope.showDrawer = false;
$scope.isFullScreen = true;
$scope.schedActive = false;
})
$(".bodycontainer").addClass("fullscreen");
$(".drawer").addClass("offpage");
$(".schedulepane").hide();
var elem = document.getElementById('liveEvent');
fullscreenAPI.RequestFullScreen(elem);
fullscreenAPI.Fullscreenchange(fullScreenOptions);
}
}
//}
})
$scope.$on('ad_ended', function() {
$scope.stopCheckAd();
lp.adComplete = true;
VideoPlayer.setParams(amp, {"siteSectionId" : "nws_noads", "noAd": "t"})
if(amp.playerType == "flash"){
amp.getMediaElement().setPlayerProperty("fullscreenBtn", {visible:true});
}
$('#help, .schedulebtn').fadeIn(200);
$(".videoplayerwrapper .adslug").hide();
$('#_fw_container_300x250slot').html('');
// $("#videoplayer, #liveEvent .mainvideobg img").animate({
// width: lp.width,
// height: lp.height
// }, 800, function(){
// $("#liveEvent #bannerad").fadeOut(200);
// $("#videoplayer, #liveEvent .mainvideobg img").attr("style", "");
// });
});
$scope.$on('paused', function(data) {
// if(!lp.pausedFromShare){
// launchPauseScreen();
// }
});
$scope.$on('share', function(event, eventData) {
if(!fullscreenAPI.isSupported()){
amp.exitFullScreen()
}
lp.pausedFromShare = true;
$("#share_overlay").fadeIn(200);
VideoPlayer.share(amp, eventData, "video-share");
});
$scope.$on('playerelementevent', function(data, eventData) {
//handle the playlist button
if(eventData.data.element == "playlistBtn" && eventData.data.type == "click"){
$scope.showDrawer = !$scope.showDrawer;
if ($scope.showDrawer){
$scope.$apply(function(){
$scope.showDrawer = true;
if(!$scope.drawerActive){
$scope.drawerActive = true;
$scope.drawerCallout = "Minimize additional streams"
}
//$scope.drawerActive = true;
});
}else{
$scope.$apply(function(){
$scope.showDrawer = false;
//$scope.drawerActive = false;
$("#livepreviews").removeAttr("style");
});
}
}
if(eventData.data.element == "fullscreenBtn" && eventData.data.type == "click"){
if(fullscreenAPI.isSupported()){
if (fullscreenAPI.isFullScreen()) {
fullscreenAPI.CancelFullScreen();
$(".bodycontainer").removeClass("fullscreen");
$(".drawer").removeClass("offpage");
$scope.showDrawer = true;
}
else {
$scope.$apply(function(){
$scope.showDrawer = false;
$scope.isFullScreen = true;
$scope.schedActive = false;
})
$(".bodycontainer").addClass("fullscreen");
$(".drawer").addClass("offpage");
$(".schedulepane").hide();
var elem = document.getElementById('liveEvent');
fullscreenAPI.RequestFullScreen(elem);
fullscreenAPI.Fullscreenchange(fullScreenOptions);
}
}
}
});
$scope.toggleDrawer = function(){
$scope.drawerActive = !$scope.drawerActive;
if(!$scope.drawerActive){
$scope.drawerCallout = "See additional streams";
}else{
$scope.drawerCallout = "Minimize additional streams";
}
$("#livepreviews").slideToggle("slow", function(){
});
}
$scope.toggleSchedule = function(){
$scope.schedActive = !$scope.schedActive;
$(".schedulepane").slideToggle("slow", function(){
});
}
//fullscreen controls when pressing escape button
$scope.toggleFullscreenControls = function(){
$scope.isFullScreenToggle = !$scope.isFullScreenToggle;
if ($scope.isFullScreenToggle){
$scope.isFullScreen = true;
$scope.showDrawer = false;
}else{
fullscreenAPI.CancelFullScreen();
$scope.isFullScreen = false;
$scope.showDrawer = true;
$(".bodycontainer").removeClass("fullscreen");
$(amp.getContainer()).removeClass("akamai-full-screen");
$(".drawer").removeClass("offpage");
}
}
launchPauseScreen = function(){
$("#pause_overlay_meta").fadeIn();
};
removePauseScreen = function(){
$("#pause_overlay_meta").fadeOut();
};
$scope.unPausePlayer = function(){
removePauseScreen();
amp.play();
}
$("#share_overlay").click(function(){
VideoPlayer.shareExit(amp, "video-share");
})
$scope.launchReminder = function(){
//setup link
var gCalURL = "http://www.google.com/calendar/render?action=TEMPLATE&text="+$scope.calEventData.title+" Live Stream+&dates="+$scope.calEventData.startTimeISO+"/"+$scope.calEventData.endTimeISO+"&details=Watch live at abcnews.com/live: "+$scope.calEventData.title+"&trp=false&sf=true&sprop=ABCNews"
var emailURL = "mailto:?subject=Reminder: "+$scope.calEventData.title+"&body=Watch live at http://abcnews.go.com/live : "+$scope.calEventData.title + " on " +$scope.calEventData.date + " at " +$scope.calEventData.startTimeText;
$("#reminder .google_calendar").attr("href", gCalURL);
$("#reminder .email").attr("href", emailURL);
//console.log($scope.calEventData)
$("#reminder").removeClass("offpage");
$("#reminder_overlay").fadeIn(200);
//console.log($(el).siblings(".info").html());
}
$scope.closeReminder = function(){
$("#reminder").addClass("offpage");
$("#reminder_overlay").fadeOut(200);
}
fullScreenOptions = function(){
if (fullscreenAPI.isFullScreen()) {
$scope.$apply(function(){
$scope.isFullScreen = true;
});
// if($scope.playlist.length > 1){
// amp.getMediaElement().setPlayerProperty("playlistBtn", {visible:true});
// }
}else {
$scope.$apply(function(){
$scope.isFullScreen = false;
});
// amp.getMediaElement().setPlayerProperty("playlistBtn", {visible:false});
// amp.getMediaElement().setPlayerProperty("fullscreenBtn", {state:"active"});
}
}
$(document).on({
'fullscreenchange': function()
{
$scope.toggleFullscreenControls();
},
'mozfullscreenchange': function()
{
$scope.toggleFullscreenControls();
},
'webkitfullscreenchange': function()
{
$scope.toggleFullscreenControls();
}
});
//$scope.hovered = false;
$("#closelightbox").click(function(){
if(typeof window.parent.vrOrigin != "undefined"){
window.parent.location = window.parent.vrOrigin;
}else{
window.parent.location = "/";
}
});
$("#help").click(function(){
lp.isHelpScreenActive = !lp.isHelpScreenActive
if(lp.isHelpScreenActive){
$("#help_overlay, #help_page_overlay").fadeIn(200);
$("#help").addClass("active");
}else{
lp.closeHelpScreen();
}
})
$("#help_page_overlay").click(function(){
lp.closeHelpScreen();
})
$(document).keyup(function(e) {
if (e.keyCode == 27) {
lp.closeHelpScreen();
}
});
angular.element(document).ready(function () {
setTimeout(function(){
$(".schedulepane").jScrollPane();
$(".schedulepane").hide().removeClass("offpage");
}, 2000)
});
var pusher = new Pusher('bbd22899e72cfe54c160');
var channel = pusher.subscribe('vcr');
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
}
var isProd = !/localhost|qa\.n7\.abcnews\.go\.com/.test(window.location.origin);
var pusherLivePageUpdateEvent = isProd ? 'desktop-livepage-update' : 'desktop-livepage-update-qa';
var pusherEventHeadlineUpdateEvent = 'desktop-events-headline-update-' + (isProd ? 'PROD' : 'QA');
if(/pusherpreview=true/.test(window.location.href)){
pusherLivePageUpdateEvent = "desktop-livepage-update-prev";
}
channel.bind(pusherEventHeadlineUpdateEvent, function(data) {
var updateId = data.id.toLowerCase();
angular.forEach($scope.playlist, function(ph, idx) {
if (!angular.equals(ph.id.toLowerCase(), updateId)) {
return;
}
ph.hed = data.hed;
ph.hedshort = data.hedshort;
//console.log(">>> pusherEventHeadlineUpdateEvent: " + ph.id.toLowerCase() + " " + $scope.mainvideo.id.toLowerCase())
if (angular.equals(ph.id.toLowerCase(), $scope.mainvideo.id.toLowerCase())) {
$scope.mainvideo.hed = ph.hed;
$scope.mainvideo.hedshort = ph.hedshort;
$(".mainvideotitle").html($scope.mainvideo.hed);
}
});
$scope.$apply();
$("#liveCarousel").jcarousel('reload');
});
channel.bind(pusherLivePageUpdateEvent, function(data){
var refreshTimeout = VideoPlayer.randomRefreshTimeout(30);
setTimeout(function() {
lp.seededbyVCR = true;
if(String(window.location).indexOf("live-0-") == -1 ){
// console.log("pusher payload data ==>")
// console.log(JSON.parse(data.data));
var phArry = JSON.parse(data.data);
var newPlaylist = [];
$scope.mainvideoNotifi = { showNotification : false, oldHed : "", newHed : "" };
angular.forEach(phArry, function(ph, idx){
if(!angular.equals(ph.id.toLowerCase(),$scope.mainvideo.id.toLowerCase())){
newPlaylist.push(ph);
}else{
if(!angular.equals(ph.hed,$scope.mainvideo.hed)){
$scope.mainvideoNotifi.showNotification = true;
$scope.mainvideoNotifi.oldHed = $scope.mainvideo.hed;
$scope.mainvideoNotifi.newHed = ph.hed;
}
$scope.mainvideo.hed = ph.hed;
$scope.mainvideo.hedshort = ph.hedshort;
$scope.mainvideo.description = ph.description;
$scope.mainvideo.image = ph.image;
$scope.mainvideo.thumb = ph.thumb;
}
});
//Message user for Main Player Change
if($scope.mainvideoNotifi.showNotification === true){
$scope.mainVideoStartNotifi("VIDEO UPDATED — "+$scope.mainvideoNotifi.oldHed+" is now "+$scope.mainvideoNotifi.newHed,false);
$(".mainvideotitle").html($scope.mainvideo.hed);
$(".mainvideodesc").html($scope.mainvideo.description);
}
//Begin MainVideo End Logic
var isMainLive = false;
angular.forEach(phArry, function(ph, idx){
if(angular.equals(ph.id.toLowerCase(),$scope.mainvideo.id.toLowerCase())){
isMainLive = true;
}
});
if(!isMainLive){
var mainVidMess = "VIDEO ENDED — "+$scope.mainvideo.hed;
$scope.mainvideo.isStarted = false;
$scope.mainVideoEndNotifi(mainVidMess, false);
}
//End MainVideo End Logic
//Build newToPlyList Array
var newToPlyList = [];
angular.forEach(newPlaylist, function(ph, idx){
var found = false;
for(var i = 0; i < $scope.playlist.length; i++) {
//console.log(">>>> is " + $scope.playlist[i].id.toLowerCase()+ " == " + ph.id.toLowerCase())
if ($scope.playlist[i].id.toLowerCase() == ph.id.toLowerCase()) {
found = true;
break;
}
}
if(!found){
newToPlyList.push(ph);
}
});
//End Build newToPlyList Array
//Message to CLient items newToPlyList Array
if(newToPlyList.length > 0){
angular.forEach(newToPlyList, function(ph, idx){
$scope.addNotifi("NEW VIDEO — "+ph.hed,false);
});
}
//Build remFromPlyList Array
var remFromPlyList = [];
angular.forEach($scope.playlist, function(ph, idx){
var found = false;
for(var i = 0; i < newPlaylist.length; i++) {
if (newPlaylist[i].id == ph.id) {
found = true;
break;
}
if (ph.id == $scope.mainvideo.id) {
found = true;
break;
}
}
if(!found){
remFromPlyList.push(ph);
}
});
//End Build remFromPlyList Array
//Message to Client items remFromPlyList Array
if(remFromPlyList.length > 0){
angular.forEach(remFromPlyList, function(ph, idx){
$scope.removedNotifi("VIDEO ENDED — "+ph.hed,false);
});
}
//Add Back the MainVideo to New Playlist
newPlaylist.unshift($scope.mainvideo);
// console.log("newPlayList = " + JSON.stringify(newPlaylist))
$scope.playlistCached = $scope.playlist;
$scope.playlist = newPlaylist;
// console.log("Value of $scope.playlist = " + JSON.stringify($scope.playlist))
$scope.$apply();
seeder();
$("#liveCarousel").jcarousel('reload');
}
}, refreshTimeout);
});
$scope.removedNotifi = function(message, clear) {
if ($scope.prevMessage != message) {
$.bootstrapGrowl(''+message, {
type: 'success',
allow_dismiss: clear,
offset: {from: 'top', amount: 747},
width: 'auto'
});
$scope.prevMessage = message;
}
};
$scope.addNotifi = function(message, clear) {
if ($scope.prevMessage != message) {
$.bootstrapGrowl(''+message, {
type: 'success',
allow_dismiss: clear,
offset: {from: 'top', amount: 747},
width: 'auto'
});
$scope.prevMessage = message;
}
};
$scope.mainVideoStartNotifi = function( message, clear) {
if ($scope.prevMessage != message) {
$.bootstrapGrowl(''+message, {
type: 'success',
allow_dismiss: clear,
offset: {from: 'top', amount: 163},
width: 'auto'
});
$scope.prevMessage = message;
}
};
$scope.mainVideoEndNotifi = function(message, clear) {
if ($scope.prevMessage != message) {
$.bootstrapGrowl(''+message, {
type: 'success',
allow_dismiss: clear,
offset: {from: 'top', amount: 163},
width: 'auto'
});
$scope.prevMessage = message;
}
};
}]);