var playerArr = []; var platform = "WEB"; if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) { platform = 'WAP'; } var loadUrl = window.location.href || ''; var player = player || undefined; var globalAgency = globalAgency || ''; var fallbackMute = true; var defaultVolume = 100; var defaultMute = 0; var defaultPageSection = "videoshow"; var playerContainerId,playerDOMObj; var videoRequestTime, timeTakenToVideoReady; window.SPLSkipGALibLoad = true; var TimesApps = window.TimesApps || {}; TimesApps.loadJs = function (url, cb, nodeid) { var head = document.getElementsByTagName('head')[0], s = document.createElement('script'); s.type = 'text/javascript'; s.src = url; s.async = true; nodeid && (s.id = nodeid); var ieCallback = function (el, callback) { if (el.readyState === 'loaded' || el.readyState === 'complete') { callback(); } else { setTimeout(function () { ieCallback(el, callback); }, 20); } }; if (typeof cb === 'function') { if (typeof s.addEventListener !== 'undefined') { s.addEventListener('load', cb, false); s.addEventListener('error', cb, false); } else { s.onreadystatechange = function () { s.onreadystatechange = null; ieCallback(s, cb); }; } } head.appendChild(s); } function _parseCookieValue ( s ) { if( s.indexOf( '"' ) === 0 ) { // This is a quoted cookie as according to RFC2068, unescape... s = s.slice( 1, -1 ).replace( /\\"/g, '"' ).replace( /\\\\/g, '\\' ); } try { // If we can't decode the cookie, ignore it, it's unusable. // Replace server-side written pluses with spaces. return decodeURIComponent( s.replace( /\+/g, ' ' ) ); } catch( e ) {} } function get_cookie( name ) { var result = name ? undefined : {}; var cookies = document.cookie ? document.cookie.split( '; ' ) : []; for( var i = 0, l = cookies.length; i < l; i++ ) { var parts = cookies[ i ].split( '=' ); var nameK = decodeURIComponent( parts.shift() ); var cookie = parts.join( '=' ); cookie = _parseCookieValue( cookie ); if( name && name === nameK ) { result = cookie; break; } if( !name && cookie !== undefined ) { result[ nameK ] = cookie; } } return result; } var checkGdprAndCall = function(callback, callbackForEu, checkForUserConsent){ try{ window.TimesGDPR = window.parent.TimesGDPR; }catch(e){} if ( window.TimesGDPR && TimesGDPR.common.consentModule.gdprCallback ){ TimesGDPR.common.consentModule.gdprCallback(function(data){ if(data && data.isEUuser && typeof callbackForEu == "function" ){ callbackForEu(); }else if( !data.isEUuser && typeof callback == "function" ){ callback(); } }); }else if(typeof callbackForEu == "function"){ callbackForEu(); } } TimesApps.prepareComscoreDataAndFireReq = function(event, eventData, eventType){ var parentWindow = window; if(typeof parentWindow == "undefined"){ return; } var parentHostname = parentWindow.location.hostname; if( parentHostname.indexOf(".jeetbetwin.com") == -1 ){ return; } if( typeof parentWindow.TimesApps == "undefined"){ return; } var config = parentWindow.TimesApps.comscoreTrackingConfig; if( typeof config == "undefined" ){ return; } var contentType = eventData.stream || ""; contentType = contentType.toUpperCase(); var trackingDetails = {}; trackingDetails.contentGenre = config.contentGenre; trackingDetails.seoLocation = playerDOMObj.getAttribute("data-seolocation"); var dateObj = playerDOMObj.getAttribute("data-artdate"); dateObj = dateObj.split("#")[1]; dateObj = new Date(Date.parse(dateObj)); dateObj = dateObj.getFullYear() + "-" + (dateObj.getMonth()+1) + "-" +dateObj.getDate(); var date = dateObj; trackingDetails.airDate = date; var videoObj = eventData || {}; videoObj.pdata = {}; videoObj.id = playerDOMObj.getAttribute("data-msid"); //converting to mins //remove once all videos are migrated to Slike videoObj.duration = ( videoObj.duration || 00 ) / 60; videoObj.title = playerDOMObj.getAttribute("data-title"); videoObj.pdata.adposition = eventData.adtype; trackingDetails.c3 = config.c3; if(typeof eventType === 'string' && eventType != "") eventType = eventType.toUpperCase(); fireComscoreTrackingRequest(config.comscoreCustomerId, eventType, contentType, config.stationTitle, config.publisherName, trackingDetails, videoObj); if( eventType == "ADSKIP" ){ TimesApps.setAdStatus(contentType,eventType); } } TimesApps.Chartbeat = (function(){ var fn, api, bindEvents; bindEvents = function(){ //checkGdprAndCall && checkGdprAndCall(fn._loadChartbeat, null); } fn = { _init : function(){ /****************************************************************************************************/ /****************************************************************************************************/ window._sf_async_config = window._sf_async_config || {}; _sf_async_config.uid = "10538"; _sf_async_config.domain = 'jeetbetwin.com/travel'; _sf_async_config.autoDetect = false; fn._prepareData(); bindEvents(); }, _loadChartbeat : function(){ window._sf_endpt = (new Date()).getTime(); var playerJs = document.createElement('script'); playerJs.src = "//static.chartbeat.com/js/chartbeat_video.js"; var scriptTag = document.getElementsByTagName('script')[0]; var onChartbeatLoad = function(){ fn._addPlayerToConfig(); } TimesApps.loadJs(playerJs.src, onChartbeatLoad,"" ); }, _prepareData : function(){ window['_cbv_strategies'] = window['_cbv_strategies'] || []; window['_cbv_strategies'].push( VideoStratgey ); }, _addPlayerToConfig : function(){ var config = getPlayerConfig(); var _cbv = window._cbv || (window._cbv = []); _cbv.push(config); } } api = { _init : function(){ fn._init(); } } return api; }()); /** * Consrtructor for the strategy. This is what gets passed to the SDK via: * window['_cbv_strategies'].push(VideoStratgey); * @param {Object} player A pointer to the player being tracked. The player * is where all the video data is derived from */ function VideoStratgey(player) { // Your constructor code goes here this.player_ = player; this.ready_ = false; this.adData = { isPlaying : false, adType :'' } } /** * Enum for the content type. One of these values should be returned from * the "getContentType" function. * @enum {string} */ VideoStratgey.ContentType = { AD: 'ad', CONTENT: 'ct' }; /** * Enum for the ad position. One of these values should be returned from * the "getAdPosition" function. * @enum {string} */ VideoStratgey.AdPosition = { PREROLL: 'a1', MIDROLL: 'a2', POSTROLL: 'a3', OVERLAY: 'a4', SPECIAL: 'a5' }; /** * Enum for the video state. One of these values should be returned from * the "getState" function. * @enum {string} */ VideoStratgey.VideoState = { UNPLAYED: 's1', PLAYED: 's2', STOPPED: 's3', COMPLETED: 's4' }; function callChartBeatBackData(eventData,eventType){ v1.subscribeEvents_(eventData,eventType); } VideoStratgey.prototype.subscribeEvents_ = function(eData,eType) { var eventData = eData; var eventType = eType; if( eventData.stream == 'AD' && eventType == 'START' ){ v1.adData.isAdPlaying = true; }else if( eventData.stream == 'AD' && ( eventType == 'ADCOMPLETE' || eventType == 'ADSKIP' || eventType == 'ERROR' ) ){ v1.adData.isAdPlaying = false; } v1.adData.adType = ( eventData.adtype || '' ).toUpperCase(); if( v1.adData.isAdPlaying ){ return; } switch(eventType ){ case 'VIDEOREADY' : v1.onPlaybackReady_(); break; case 'VIDEOVIEW' : v1.onVideoPlay_(); break; } } /** * Handle when the video is ready for playback * @private */ VideoStratgey.prototype.onPlaybackReady_ = function() { //console.log('**********************************VideoStratgey::onPlaybackReady_'); this.ready_ = true; }; /** * Handle when the video is played * @private */ VideoStratgey.prototype.onVideoPlay_ = function() { //console.log('**********************************VideoStratgey::onVideoPlay_'); this.videoStartTime_ = Date.now(); this.videoPlayed_ = true; }; /** * Indicates if the video strategy is ready for pinging. * Typically this is called when all path and title metadata * is available * Note: Pings should only be sent after this reads true. * @return {boolean} The ready state of the strategy. */ VideoStratgey.prototype.isReady = function() { // As an example, this could just be a call to a similar // method in your _player object // this._player.isready(); //console.log("*************** isReady called *****************************"); return this.ready_; }; VideoStratgey.verify = function(player) { //console.log("*************** verify called *****************************"); //return player.playerVars.id === playerDOMObj.getAttribute("data-slikeid"); }; /** * Gets the video path. * This is returned in the p key of the ping. * Note: this should be the playable video path if available. * @return {string} The video path. */ VideoStratgey.prototype.getVideoPath = function() { //console.log("*************** getVideoPath called *****************************"); return playerDOMObj.getAttribute("data-slikeid"); }; /** * Gets the type of video playing. Returns value from the ContentType enum. * This is returned in the _vt key of the ping. * @return {YourStrategy.ContentType} The type of content (ad or ct). */ VideoStratgey.prototype.getContentType = function() { if( this.adData.isAdPlaying ){ return VideoStratgey.ContentType.AD; //console.log("*************** getContentType called -" + VideoStratgey.ContentType.AD +"*****************************"); } //console.log("*************** getContentType called " + VideoStratgey.ContentType.CONTENT +"*****************************"); return VideoStratgey.ContentType.CONTENT; }; VideoStratgey.prototype.getAdPosition = function() { var adPosition; switch(this.adData.adType){ case 'MID': adPosition = VideoStratgey.AdPosition.PREROLL break; } //console.log("*************** getAdPosition called,"+ adPosition +"*****************************"); return adPosition; }; VideoStratgey.prototype.getState = function() { var FLAGS = TimesApps.FLAGS; var playerState = TimesApps.VideoPlayer2.getPlayerState() || ""; var state; if( this.adData.isAdPlaying ){ //in case of ads //paused is to be sent state = VideoStratgey.VideoState.STOPPED; }else{ switch(playerState){ case TimesApps.FLAGS.READY: state = VideoStratgey.VideoState.UNPLAYED break; case TimesApps.FLAGS.PLAYING: state = VideoStratgey.VideoState.PLAYED break; case TimesApps.FLAGS.PAUSED: state = VideoStratgey.VideoState.STOPPED break; case TimesApps.FLAGS.COMPLETED: state = VideoStratgey.VideoState.COMPLETED break; default: state = VideoStratgey.VideoState.STOPPED } } //console.log("*************** getState called," + state + "*****************************"); return state; }; VideoStratgey.prototype.getStrategyName = function(){ return 'VS'; } VideoStratgey.prototype.getTitle = function() { //console.log("*************** getTitle called *****************************"); return playerDOMObj.getAttribute("data-title") || ""; }; VideoStratgey.prototype.getThumbnailPath = function() { //console.log("*************** getThumbnailPath *****************************"); return playerDOMObj.getAttribute("data-bgImg") || ""; } VideoStratgey.prototype.getTotalDuration = function() { //console.log("*************** getTotalDuration called - " + TimesApps.Vod_Player.getDurationinMs() + "*****************************"); return playerDOMObj.getAttribute("data-duration"); } VideoStratgey.prototype.getCurrentPlayTime = function(){ var currentPlayTimeInS = player && player.getCurrentPosition && player.getCurrentPosition(); //console.log("*************** getCurrentPlayTime -" + Math.round(currentPlayTimeInS * 1000) + "*****************************"); return Math.round(currentPlayTimeInS * 1000); } VideoStratgey.prototype.getViewStartTime = function(){ return 0; } var v1 = new VideoStratgey(player); TimesApps.Chartbeat._init(); var TimesApps = window.TimesApps || {}; TimesApps.ComscoreConfig = TimesApps.ComscoreConfig || {}; checkGdprAndCall && checkGdprAndCall(null, function(){ TimesApps.ComscoreConfig['cs_ucfr'] = 0; }, false); //flag to check if next video has been played by the player //used in case of videoshow and videolist TimesApps.playingSubsequentVideo = false; TimesApps.videoEventsMap = { "START" : "START", "STOP" : "STOP", "PAUSED" : "PAUSED", "ADCOMPLETE" : "ADCOMPLETE" } /* *remvoe fn post Slike migration * check point, CMS INSERTED LIVE TV */ var convertMinutesToMs = function(timeInMinutes){ var timeInMs = 0; if( typeof timeInMinutes != "undefined" ){ var timeSplit = timeInMinutes.toString().split(":"); var SECONDS_IN_A_MINUTE = 60; var MS_IN_A_SECOND = 1000; if(timeSplit.length ==2){ timeInMs = timeSplit[0] * SECONDS_IN_A_MINUTE * MS_IN_A_SECOND; timeInMs += timeSplit[1] * MS_IN_A_SECOND; }else if(timeSplit.length ==1){ timeInMs = timeSplit[0] * SECONDS_IN_A_MINUTE * MS_IN_A_SECOND; } } return timeInMs; } /* currently moved to vod_player_js remove after moving to Utils for vod, live, minitv */ TimesApps.convertMinutesToMs = TimesApps.convertMinutesToMs || convertMinutesToMs; TimesApps.setAdStatus = function(contentType,eventType, adDuration){ if( contentType == "AD" ){ if( eventType == "PAUSED" ){ TimesApps.adStatus = "PAUSED"; }else if( eventType == "START" ){ TimesApps.adStatus = "PLAYING"; }else if( eventType == "ADCOMPLETE" ){ TimesApps.adStatus = "ADCOMPLETE"; TimesApps.isServingAdInFlashPlayer = false; } else if( eventType == "ADSKIP" ){ TimesApps.adStatus = "ADSKIP"; TimesApps.isServingAdInFlashPlayer = false; } else if( eventType == "ADDURATION" ){ //hack for flash players ( livetv, mini ) //as insufficient data //is available with events in such cases TimesApps.isServingAdInFlashPlayer = true; TimesApps.adDuration = adDuration; } }else{ //request was for content video //implies that ad has been skipped TimesApps.adStatus = "ADCOMPLETE"; TimesApps.isServingAdInFlashPlayer = false; } } var fireComscoreTrackingRequest = function(comscoreCustomerId, eventType, contentType, stationTitle, publisherName, trackingDetails, videoObj){ if( typeof window.myStreamingTag == 'undefined' || eventType == "REPLAY" ){ window.myStreamingTag = new ns_.StreamingTag({ customerC2: comscoreCustomerId }); } if( typeof TimesApps.videoEventsMap[eventType] == "undefined" ){ //event is not in list of events to track return; } if( typeof comscoreCustomerId == 'undefined' || comscoreCustomerId == '' ){ return; } if( TimesApps.isServingAdInFlashPlayer ){ contentType = "AD"; } try{ if( eventType == "START" || eventType == 'PLAYING' || eventType == 'ADVIEW' ){ if(contentType == "AD"){ if( TimesApps.adStatus == "PAUSED" ){ //ad was paused and has just switched to playing status //tracking not required return; } var adStr = ""; if( typeof videoObj.pdata == "undefined" ){ return; } var adposition = videoObj.pdata.adposition || ""; if( adposition.toUpperCase() == "PRE"){ adStr = ns_.StreamingTag.AdType.LinearOnDemandPreRoll; }else{ adStr = ns_.StreamingTag.AdType.LinearOnDemandPostRoll; } adDurationInMinutesFormat = "00:" + (videoObj.duration || videoObj.pdata.tottime || 00 ); var adDuration = TimesApps.convertMinutesToMs(adDurationInMinutesFormat); myStreamingTag.playVideoAdvertisement({ ns_st_cl: adDuration }, adStr); }else{ var seoLocation = trackingDetails.seoLocation.split("/"); if( seoLocation.length >= 2 ){ var seoLocationWithoutTitle = seoLocation.length -1; seoLocation = seoLocation.slice(0, seoLocationWithoutTitle).join("/"); }else{ seoLocation = trackingDetails.seoLocation; } var videoDuration = TimesApps.convertMinutesToMs(videoObj.duration); var metd = { "ns_st_ci": videoObj.id || videoObj.videoid || 0, "ns_st_cl": videoDuration || 0, "ns_st_st": stationTitle, "ns_st_pu": publisherName, "ns_st_pr": seoLocation, "ns_st_ep": videoObj.title, "ns_st_sn": "*null", "ns_st_en": "*null", "ns_st_ge": trackingDetails.contentGenre, "ns_st_ti": "*null", "ns_st_ia": "0", "ns_st_ce": "0", "ns_st_ddt": trackingDetails.airDate, "ns_st_tdt": trackingDetails.airDate, "c3": trackingDetails.c3 || "*null", "c4": "*null", "c6": "*null" } if( TimesApps.ComscoreConfig.hasOwnProperty('cs_ucfr') && TimesApps.ComscoreConfig['cs_ucfr'] === 0 ){ metd['cs_ucfr'] = TimesApps.ComscoreConfig['cs_ucfr']; } myStreamingTag.playVideoContentPart(metd, ns_.StreamingTag.ContentType.ShortFormOnDemand); } }else if(!(contentType == "AD" && eventType != "ADCOMPLETE" )){ //STOP, VIDEOCOMPLETE, PAUSED myStreamingTag.stop(); } TimesApps.setAdStatus(contentType,eventType); }catch(e){} } var etimes_video_ga = (function () { function saveVideoRequestTime() { videoRequestTime = Date.now(); } function fetchTimeTakeToVideoReady() { return timeTakenToVideoReady = Date.now() - videoRequestTime + 'ms_'; } function fetchIsUserInitiated() { return (isUserInitiated == true) ? "user-initiated" : "autoplay"; } function fetchCurrentSeolocation() { return playerDOMObj.getAttribute("data-seolocation"); } function fetchCurrentMsid() { return playerDOMObj.getAttribute("data-msid"); } function fetchCurrentAgency() { return (playerDOMObj.getAttribute("data-agency") != "" && playerDOMObj.getAttribute("data-agency") != "undefined") ? playerDOMObj.getAttribute("data-agency") : "TNN"; } function fetchCampaign() { return (playerDOMObj.getAttribute("data-campaign") != "" && playerDOMObj.getAttribute("data-campaign") != "undefined") ? "_"+playerDOMObj.getAttribute("data-campaign") : ""; } function sendGAEvent(category, action, label) { if (typeof (ga) == "function") ga('send', 'event', category, action, label); } function getEventAction() { return fetchIsUserInitiated() + "_" + fetchCurrentSeolocation() + "/" + fetchCurrentMsid() + "_" + fetchCurrentAgency() + fetchCampaign(); } function getEventLabel() { var _sourceval = (playerDOMObj.getAttribute("data-source") !="")?playerDOMObj.getAttribute("data-source") : defaultPageSection; return platform + "_" + _sourceval; } function sendSlikeJsLoadRequest() { sendGAEvent("SLIKEREQUESTED", getEventAction(), getEventLabel()) } function sendSlikeLoaded() { sendGAEvent("SLIKELOADED", getEventAction(), getEventLabel()) } function sendSlikeError() { sendGAEvent("SLIKELOADFAIL", getEventAction(), getEventLabel()) } function getEmbedSource(){ return (playerDOMObj.getAttribute("data-source") == "audioembed" ) ? "AUDIO" : "VIDEO"; } function sendVideoRequest() { saveVideoRequestTime(); sendGAEvent(getEmbedSource() + "REQUEST", getEventAction(), getEventLabel()) } function sendVideoError(errmessage) { sendGAEvent(getEmbedSource() +"ERROR", getEventAction(), getEventLabel() + "/" + errmessage) } function sendVideoReady() { sendGAEvent(getEmbedSource() +"READY", fetchTimeTakeToVideoReady() + getEventAction(), getEventLabel()) } function sendVideoView() { sendGAEvent(getEmbedSource() +"VIEW", getEventAction(), getEventLabel()) // TimesApps.iBeat.loadiBeat(); } function sendVideoComplete(duration) { sendGAEvent(getEmbedSource() +"COMPLETE", getEventAction() + "_" + parseInt(duration) + "s", getEventLabel()) } function sendAdRequest(identifier) { sendGAEvent("ADREQUEST", identifier + "/" + getEventAction(), getEventLabel()) } function sendAdError(identifier) { sendGAEvent("ADERROR", identifier + "/" + getEventAction(), getEventLabel()) } function sendAdLoaded(identifier) { sendGAEvent("ADLOADED", identifier + "/" + getEventAction(), getEventLabel()) } function sendAdView(identifier) { sendGAEvent("ADVIEW", identifier + "/" + getEventAction(), getEventLabel()) } function sendAdComplete(identifier) { sendGAEvent("ADCOMPLETE", identifier + "/" + getEventAction(), getEventLabel()) } function sendAdSkip(identifier) { sendGAEvent("ADSKIP", identifier + "/" + getEventAction(), getEventLabel()) } return { _sendSlikeJsLoadRequest: function () { sendSlikeJsLoadRequest(); }, _sendSlikeLoaded: function () { sendSlikeLoaded(); }, _sendSlikeError: function () { sendSlikeError(); }, _sendVideoRequest: function () { sendVideoRequest(); }, _sendVideoError: function (errmessage) { sendVideoError(errmessage); }, _sendVideoReady: function () { sendVideoReady(); }, _sendVideoView: function () { sendVideoView(); }, _sendVideoComplete: function (duration) { sendVideoComplete(duration); }, _sendAdRequest: function (identifier) { sendAdRequest(identifier); }, _sendAdError: function (identifier) { sendAdError(identifier); }, _sendAdLoaded: function (identifier) { sendAdLoaded(identifier); }, _sendAdView: function (identifier) { sendAdView(identifier); }, _sendAdComplete: function (identifier) { sendAdComplete(identifier); }, _sendAdSkip: function (identifier) { sendAdSkip(identifier); } } }()); function getDataFromSessionStorage(key) { var data; try { data = sessionStorage.getItem(key); } catch (e) { etimes_video_ga._sendVideoError("Error : " + e.message); } return data; } function setIntoSessionStorage(key, value) { if (typeof key == "undefined" || key.trim().length == 0) { return; } try { sessionStorage.setItem(key, value); } catch (e) { etimes_video_ga._sendVideoError("Error : " + e.message); } } function onJSLoadError(type) { switch (type) { case 'slike': etimes_video_ga._sendSlikeError(); break; } } function onJSLoaded(type) { switch (type) { case 'slike': etimes_video_ga._sendSlikeLoaded(); break; } } function getPageSection() { var breadcrumVal = ($('[typeof="ListItem"]').length > 1) ? $('[typeof="ListItem"]').text().split(" / ").slice(0, -1).join(".") : defaultPageSection; if (breadcrumVal && breadcrumVal != "") { return breadcrumVal; } } function getPlayerVolume() { return (getDataFromSessionStorage("volume")) ? parseInt(getDataFromSessionStorage("volume")) : defaultVolume } function setPlayerVolume(volume) { setIntoSessionStorage("volume", volume); } function getSGParams() { var audienceParamsOutput, _audienceDataArray = [], _BL_pg, _hyp1 = $("#" + playerContainerId).attr("data-specialidhyp1"); var continentAllowed = continentAllowed || ''; if (typeof (geoinfo) !== "undefined" && typeof (geoinfo.Continent) == "string" && continentAllowed.indexOf(geoinfo.Continent.toLowerCase()) !== -1) { window._ccaud = undefined; } var ccaud = window._ccaud; if ( typeof (ccaud) != 'undefined' && ccaud.Profile && ccaud.Profile.Audiences && ccaud.Profile.Audiences.Audience ) { for (var i = 0; (i < ccaud.Profile.Audiences.Audience.length && i < 200); i++) { _audienceDataArray.push(ccaud.Profile.Audiences.Audience[i].abbr); } } audienceParamsOutput = _audienceDataArray.join(','); if (typeof _hyp1 === 'string' && _hyp1.length) { audienceParamsOutput += ',&hyp1=' + _hyp1; } audienceParamsOutput = decodeURIComponent(audienceParamsOutput); return audienceParamsOutput; } function getBgImg() { if (playerDOMObj.getAttribute("data-refreshed") == "0" && playerDOMObj.getAttribute("data-bgImg") != null && playerDOMObj.getAttribute("data-bgImg") != "") { return playerDOMObj.getAttribute("data-bgImg") } else { var msidVal = playerDOMObj.getAttribute("data-msid"); var imgPath = "http://static.toiimg.com/thumb/msid-" + msidVal + ",width-800,resizemode-4/" + msidVal + ".jpg"; return imgPath; } } function getUserCountry() { var geoinfo = window.geoinfo; var countryCode; if (geoinfo != "" && geoinfo && geoinfo.CountryCode && geoinfo.CountryCode != '') { countryCode = geoinfo.CountryCode;; } else { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "//geoapi.jeetbetwin.com/?cb=1"; script.async = "async"; script.onload = function () { var geoinfo = window.geoinfo; countryCode = geoinfo.CountryCode; } document.head.appendChild(script); } return countryCode; } function playVideoFromPlayList(index, player) { if (window.playListObj != undefined && window.playListObj != null && typeof window.playListObj != "undefined") { if (window.playListObj.playlist != undefined && window.playListObj.playlist.length > 1) { player = player || window.player; var nextvideodata; var playerObj = playerDOMObj; if (typeof index === 'number' && !isNaN(index) && index > -1) { // Notify: Changed condition here nextvideodata = window.playListObj.playlist[index]; playerObj.setAttribute("data-userinitiated", "1"); window.playListObj.callbacks.onTerminate(index); window.playListObj.currentIndex = index; } else { nextvideodata = window.playListObj.playlist[window.playListObj.nextIndex]; playerObj.setAttribute("data-userinitiated", "0"); window.playListObj.callbacks.onEnded(); window.playListObj.currentIndex = window.playListObj.nextIndex; } var slikeId = nextvideodata.media.slikeid; var videoMsid = nextvideodata.msid; var seoLocation = nextvideodata.media.seolocation; var playerType = nextvideodata.media.rmid; var videoTitle = nextvideodata.media.videoheading; var videoAgency = nextvideodata.media.agency; var skipAds = (nextvideodata.media.skipads == "1") ? true : false; var bgImg = getBgImg(); var sg = getSGParams(); playerObj.setAttribute("data-msid", videoMsid); playerObj.setAttribute("data-slikeid", slikeId); playerObj.setAttribute("data-seolocation", seoLocation); playerObj.setAttribute("data-rmid", playerType); playerObj.setAttribute("data-title", videoTitle); playerObj.setAttribute("data-agency", videoAgency); playerObj.setAttribute("data-skipads", nextvideodata.media.skipads); playerObj.setAttribute("data-refreshed", "1"); isUserInitiated = (playerDOMObj.getAttribute("data-userinitiated") == "1") ? true : false; player.setPlayerConfig({ player: { skipAd: skipAds } }); // TODO: do we need to skip ad on playlist next item etimes_video_ga._sendVideoRequest(); // Notify: Added video request on playlist next item player.endScreen.hide(); player.load({ id: slikeId, playerType: playerType, image: bgImg, title: videoTitle, shareUrl: loadUrl, startTime: 0, pid: videoAgency, sg: sg, sp: "embed", msid: videoMsid }); window.playListObj.nextIndex = window.playListObj.currentIndex + 1; if (window.playListObj.nextIndex == window.playListObj.playlist.length) { window.playListObj.nextIndex = 0; } } } } function getMuteVal() { return (getDataFromSessionStorage("isMute")) ? getDataFromSessionStorage("isMute") : defaultMute; } function setPlayerMuteVal(muteVal) { muteVal = (muteVal == true) ? 1 : 0; setIntoSessionStorage("isMute", muteVal); } function getPlayerConfig() { var slikeId = playerDOMObj.getAttribute("data-slikeid"); var playerType = playerDOMObj.getAttribute("data-rmid"); // Notify: Need to disucss it with Pallav var bgImg = getBgImg(); var videoTitle = playerDOMObj.getAttribute("data-title"); var autoPlay = (playerDOMObj.getAttribute("data-autoplay") == "1") ? true : false; var isMute = (getMuteVal() == "1") ? true : false; var skipAds = (playerDOMObj.getAttribute("data-skipads") == "1") ? true : false; var adSection = playerDOMObj.getAttribute("ad-section") || "default"; // Notify: added new dom attribute for ad section //var adSection = "default"; var volume = getPlayerVolume(); var pagetpl = playerDOMObj.getAttribute("data-source"); var pageSection = getPageSection(); var sg = getSGParams(); var videoMsid = playerDOMObj.getAttribute("data-msid"); var videoAgency = playerDOMObj.getAttribute("data-agency"); globalAgency = videoAgency; var playerConfig = { apiKey: "toi361web5awv9l9gzk", contEl: playerContainerId, // env: 'stg', // version: '3.5.4', // debug:true, GDPR_MODE: window.TimesGDPR.common.consentModule.isEUuser(), // TODO: Get GDPR value colombiaCookieId: (get_cookie("_col_uuid") != "" && typeof get_cookie("_col_uuid") != 'undefined') ? get_cookie("_col_uuid") : '', // TODO: Colombia cookie id gaId: '', video: { id: slikeId, playerType: playerType, image: bgImg, title: videoTitle, shareUrl: loadUrl, startTime: 0, pid: videoAgency, sg: sg, sp: "embed", msid: videoMsid }, player: { autoPlay: autoPlay, fallbackMute: fallbackMute, mute: isMute, skipAd: skipAds, adSection: adSection, volume: volume, tpAds: ["dm"], pagetpl: pagetpl, pageSection: pageSection, scrollBehaviour: { inViewPercent: 50, dock: false, autoPlay: false, autoPause: true } } }; if(pagetpl == "audioembed"){ playerConfig.controls = { ui: "podcast", theme: "wave", themeClass: "__whiteTheme" }; playerConfig.player.skipAd = true; } return playerConfig; } function playerEventsFn() { var videoAgency = playerDOMObj.getAttribute("data-agency"); return { onPlayerError: function(player, eventName, eventData) { var eventType = "VIDEOERROR"; etimes_video_ga._sendVideoError("Error : " + eventName + " - " + eventData.code); }, onInit: function(player, eventName, eventData) { var eventType = "VIDEOINIT"; etimes_video_ga._sendVideoReady(); // Notify: This was earlier video ready event TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventType); }, onVideoStarted: function(player, eventName, eventData) { var eventType = "VIDEOVIEW"; etimes_video_ga._sendVideoView(); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventType); }, onVideoResumed: function(player, eventName, eventData) { var eventType = "PLAYING"; // TODO: event changed for start TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventType); }, onVideoPaused: function(player, eventName, eventData) { var eventType = "PAUSED"; TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventType); }, onVolumeChange: function(player, eventName, eventData) { var volume = player.getVideoState().volume; setPlayerVolume(volume); if(volume > 0) { setPlayerMuteVal(false); } }, onVideoMuted: function(player, eventName, eventData) { setPlayerMuteVal(true); }, onVideoCompleted: function(player, eventName, eventData) { if (videoAgency != "YouTube") { etimes_video_ga._sendVideoComplete(player.getVideoState().duration); } }, onVideoEnded: function(player, eventName, eventData) { var eventType = "VIDEOCOMPLETE"; if (videoAgency == "YouTube") { etimes_video_ga._sendVideoComplete(player.getVideoState().duration); } playVideoFromPlayList(null, player); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventType); } } }; function adEventsFn() { var eventNameMap = { "onAdResume": "PLAYING", "onAdStart": "ADVIEW", "onAdPause": "PAUSED", "onAdComplete": "ADCOMPLETE", "onAdSkip": "ADSKIP", "onAdRequest": "ADREQUEST", "onAdLoaded": "AdLoaded", "onAdError": "ERROR" }; return { onAdComplete: function(player, eventName, eventData) { etimes_video_ga._sendAdComplete(eventData.type); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdSkip: function(player, eventName, eventData) { etimes_video_ga._sendAdSkip(eventData.type); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdLoaded: function(player, eventName, eventData) { etimes_video_ga._sendAdLoaded(eventData.type); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdRequest: function(player, eventName, eventData) { etimes_video_ga._sendAdRequest(eventData.type); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdError: function(player, eventName, eventData) { etimes_video_ga._sendAdError(eventData.type); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdResume: function(player, eventName, eventData) { TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdStart: function(player, eventName, eventData) { etimes_video_ga._sendAdView(eventData.type); TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); }, onAdPause: function(player, eventName, eventData) { TimesApps.prepareComscoreDataAndFireReq({}, eventData, eventNameMap[eventName]); callChartBeatBackData(eventData, eventNameMap[eventName]); } } }; function handlePlayerEvents(player) { var eventToFunction = function(player, eventName, data) { var funcName = eventName.replace('spl', 'on'); var eventData = data || {}; eventData.userInitiated = (isUserInitiated == true) ? "user-initiated" : "autoplay"; // TODO: what is is user initiated eventData.source = "videoshow"; if (typeof playerEvents[funcName] === 'function') { playerEvents[funcName](player, eventName, eventData); } }; Object.keys(SlikePlayer.Events).forEach(function(eventKey) { var eventName = SlikePlayer.Events[eventKey]; player.on(eventName, eventToFunction.bind(null, player)); }); } function handleAdEvents(player) { var eventToFunction = function(player, eventName, data) { var funcName = eventName.replace('spl', 'on'); var eventData = data || {}; if (typeof adEvents[funcName] === 'function') { adEvents[funcName](player, funcName, eventData); } }; Object.keys(SlikePlayer.AdEvents).forEach(function(eventKey) { var eventName = SlikePlayer.AdEvents[eventKey]; player.on(eventName, eventToFunction.bind(null, player)); }); } function createPlayer(playerConfig , _msid) { var player = new SlikePlayer(playerConfig); handlePlayerEvents(player); handleAdEvents(player); window.player = player; if(typeof window.player != "undefined"){ playerArr[_msid] = window.player; } } function loadPlayer(_msid) { etimes_video_ga._sendSlikeJsLoadRequest(); // Notify: New event var playerConfig = getPlayerConfig(); if(typeof SlikePlayer === "function"){ etimes_video_ga._sendVideoRequest(); // Notify: Changed video request position createPlayer(playerConfig,_msid); } else{ spl.load(playerConfig, function (sdkLoadStatus) { if (sdkLoadStatus) { etimes_video_ga._sendVideoRequest(); // Notify: Changed video request position createPlayer(playerConfig,_msid); } else { etimes_video_ga._sendSlikeError(); // Notify: New event added } }); } } function setGlobalParamsForLoadVideo(_msid){ window.platform = "WEB"; if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) { window.platform = 'WAP'; } window.loadUrl = window.location.href || ''; if(typeof window.player != "undefined"){ window.player.pause(); } else{ window.player = undefined; } window.globalAgency = ''; window.fallbackMute = true; window.defaultVolume = 100; window.defaultMute = 0; //window.playListObj={}; window.defaultPageSection = "videoshow"; window.playerContainerId = "playerContainer-"+_msid; window.playerDOMObj = document.getElementById(playerContainerId); window.playerEvents = playerEventsFn(); window.adEvents = adEventsFn(); window.isUserInitiated = ( playerDOMObj.getAttribute("data-userinitiated") == "1" ) ? true : false; window.videoRequestTime = undefined; window.timeTakenToVideoReady = undefined; window.SPLSkipGALibLoad = true; loadPlayer(_msid); }