Fetching more content…
Fetching more content…
‘);
fpCustomSeekFront = getFirstElementWithClassName(root, ‘fp-custom-seek-front’);
if (fpCustomSeekFront) {
fpCustomSeekFront.addEventListener(‘click’, function(e){
var api = videoPlayers[typeOfPlayer + videoId];
api.seek(true);
});
}
}
var fpCustomSeekBack = getFirstElementWithClassName(root, ‘fp-custom-seek-back’);
if (!fpCustomSeekBack) {
fpUI.insertAdjacentHTML(‘beforeend’, ”);
fpCustomSeekBack = getFirstElementWithClassName(root, ‘fp-custom-seek-back’);
if (fpCustomSeekBack) {
fpCustomSeekBack.addEventListener(‘click’, function(e){
var api = videoPlayers[typeOfPlayer + videoId];
api.seek(false);
});
}
}
var fpCustomPause = getFirstElementWithClassName(root, ‘fp-custom-pause’);
if (!fpCustomPause) {
fpUI.insertAdjacentHTML(‘beforeend’, ”);
fpCustomPause = getFirstElementWithClassName(root, ‘fp-custom-pause’);
if (fpCustomPause) {
fpCustomPause.addEventListener(‘click’, function(e){
var api = videoPlayers[typeOfPlayer + videoId];
api.toggle();
});
}
}
var fpCustomPlay = getFirstElementWithClassName(root, ‘fp-custom-play’);
if (!fpCustomPlay) {
fpUI.insertAdjacentHTML(‘beforeend’, ”);
fpCustomPlay = getFirstElementWithClassName(root, ‘fp-custom-play’);
if (fpCustomPlay) {
fpCustomPlay.addEventListener(‘click’, function(e){
var api = videoPlayers[typeOfPlayer + videoId];
api.toggle();
})
}
}
if (!!videoDuration) {
var fpCustomDuration = getFirstElementWithClassName(root, ‘fp-custom-duration’);
if (!fpCustomDuration) {
fpUI.insertAdjacentHTML(‘beforeend’, ‘
‘ + videoDuration + ‘
‘);
}
fpCustomDuration = getFirstElementWithClassName(root, ‘fp-custom-duration’);
if (fpCustomDuration) {
fpCustomDuration.innerHTML = secondsToMinutes(parseInt(fpCustomDuration.innerHTML));
}
}
if (videoViews > 100) {
var fpCustomViews = getFirstElementWithClassName(root, ‘fp-custom-views’);
if (!fpCustomViews) {
if (videoViews >= 1000) {
videoViews = Math.round((videoViews / 1000) * 10) / 10 + ‘k views’;
} else {
videoViews = videoViews + ‘ views’;
}
fpUI.insertAdjacentHTML(‘beforeend’, ‘
‘ + videoViews + ‘
‘);
}
}
}
}
var getQueryParam = function(param) {
var found;
window.location.search.substr(1).split(“&”).forEach(function(item) {
if (param == item.split(“=”)[0]) {
found = item.split(“=”)[1];
}
});
return found;
};
function getKey1UrlParamPart() {
var key1 = getQueryParam(‘key1’);
if (key1) {
return “%26key1%3D” + key1;
} else {
return “”;
}
}
function configurePlayer(videoId, videoUserId, videoTitle, videoSlug, videoImage, videoDuration, videoViews, videoAutoPlay) {
if (!window.hasOwnProperty(‘flowplayer’)) {
console.log(‘calling configurePlayer: flowplayer not on window’);
return;
}
var playerConfiguration = {
analytics: ‘UA-10769778-1’,
hlsQualities: ‘drive’,
ima: {
ads: [{
time: 0,
adTag: “https://pubads.g.doubleclick.net/gampad/ads?sz=400×300|640×480&iu=/11446729/Video_adx&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=[timestamp]&cust_params=pagetype%3DVideopage%26sport%3D%26Slug%3D” + videoSlug.substr(0,40) + getKey1UrlParamPart()
}]
},
clip: {
sources: [
{
type: “application/x-mpegurl”,
src: “//cdn.flowplayer.org/” + videoUserId + “/” + videoId + “.m3u8”
},
{
type: “video/mp4”,
src: “//cdn.flowplayer.org/” + videoUserId + “/” + videoId + “.mp4”
}
],
title: videoTitle,
},
autoplay: videoAutoPlay ? true : false,
splash: videoAutoPlay ? false : videoImage,
muted: false,
twitter: false,
mouseoutTimeout: 1200,
embed: {
‘iframe’: ‘https://www.sportskeeda.com/video/embed/’ + videoSlug
}
}
flowplayer(function(api, root) {
api.on(‘ready’, function() {
var fpElapsed = getFirstElementWithClassName(root, ‘fp-elapsed’)
var fpElapsedDivider = getFirstElementWithClassName(root, ‘fp-elapsed-divider’);
if (!fpElapsedDivider && fpElapsed) {
fpElapsed.insertAdjacentHTML(‘afterend’, ‘
/
‘)
}
var fpTimeline = getFirstElementWithClassName(root, ‘fp-timeline’);
if (fpTimeline) {
var fpDuration = getFirstElementWithClassName(root, ‘fp-duration’);
if (fpDuration) {
fpTimeline.insertAdjacentHTML(‘beforebegin’, fpDuration.outerHTML);
fpDuration.parentNode.removeChild(fpDuration);
}
}
var fpControls = getFirstElementWithClassName(root, ‘fp-controls’);
if (fpControls) {
var fpFullscreen = getFirstElementWithClassName(root, ‘fp-fullscreen’);
if (fpFullscreen) {
fpControls.appendChild(fpFullscreen);
}
}
});
api.on(“pause”, function () {
root.querySelector(“.fp-play”).className += ” fp-visible”;
});
});
var playerInFeed = document.getElementById(‘player-‘ + videoId);
if (playerInFeed && videoPlayers.hasOwnProperty(‘player-‘ + videoId)) {
return;
}
if (playerInFeed) {
setTimeout(function() {
addCustomControlsToFP(playerInFeed, videoId, videoUserId, videoTitle, videoSlug, videoImage, videoDuration, videoViews, ‘player-‘);
}, 0);
videoPlayers[‘player-‘ + videoId] = flowplayer(‘#player-‘ + videoId, playerConfiguration);
}
var playerInWidget = document.getElementById(‘player-widget-‘ + videoId);
if (playerInWidget && videoPlayers.hasOwnProperty(‘player-widget-‘ + videoId)) {
return;
}
if (playerInWidget) {
setTimeout(function() {
addCustomControlsToFP(playerInWidget, videoId, videoUserId, videoTitle, videoSlug, videoImage, videoDuration, videoViews, ‘player-widget-‘);
}, 0);
videoPlayers[‘player-widget-‘ + videoId] = flowplayer(‘#player-widget-‘ + videoId, playerConfiguration);
}
var playerResumeFn = function (e, api) {
if (trackVideoLiveTimers.hasOwnProperty(‘player-‘ + videoId)) {
console.log(‘Tracking timer already started for player-‘ + videoId);
} else {
var title = encodeURIComponent(videoTitle);
var url = encodeURIComponent(“https://www.sportskeeda.com/video/” + videoSlug);
track_video_users_live(title, url, api);
trackVideoLiveTimers[‘player-‘ + videoId] = setInterval(track_video_users_live.bind(this, title, url, api), 60 * 1000);
}
if (updatedReadCountForPlayers.hasOwnProperty(‘player-‘ + videoId)) {
console.log(‘Read count already updated for player-‘ + videoId);
} else {
try {
updateReadCount(videoSlug);
updatedReadCountForPlayers[‘player-‘ + videoId] = true;
ga(‘send’, ‘event’, ‘VIDEO’, ‘play’, videoTitle, 1, { nonInteraction: true });
} catch (err){
console.log(err);
}
}
}
if (playerInFeed) {
videoPlayers[‘player-‘ + videoId].on(‘resume’, playerResumeFn);
}
if (playerInWidget) {
videoPlayers[‘player-widget-‘ + videoId].on(‘resume’, playerResumeFn);
}
var playerIMAAdLoadedFn = function (e, api, ad) {
// is this a linear ad?
console.info(“Ad isLinear: “, ad.isLinear());
api.seek(0);
}
if (playerInFeed) {
videoPlayers[‘player-‘ + videoId].on(“ima_ad_loaded”, playerIMAAdLoadedFn);
}
if (playerInWidget) {
videoPlayers[‘player-widget-‘ + videoId].on(“ima_ad_loaded”, playerIMAAdLoadedFn);
}
var playerIMAAdErrorFn = function (e, api, err) {
console.info(“Ad error message: ” + err.message);
console.info(“Ad error code: ” + err.code);
}
if (playerInFeed) {
videoPlayers[‘player-‘ + videoId].on(“ima_ad_error”, playerIMAAdErrorFn);
}
if (playerInWidget) {
videoPlayers[‘player-widget-‘ + videoId].on(“ima_ad_error”, playerIMAAdErrorFn);
}
var playerErrorFn = function (e, api, err) {
if (err.hasOwnProperty(‘message’)) {
ga(‘send’, ‘event’, ‘VIDEO’, ‘error’, videoSlug + ‘-‘ + err.message, { nonInteraction: true });
} else {
ga(‘send’, ‘event’, ‘VIDEO’, ‘error’, ‘Unknown error’, { nonInteraction: true });
}
}
if (playerInFeed) {
videoPlayers[‘player-‘ + videoId].on(“error”, playerErrorFn);
}
if (playerInWidget) {
videoPlayers[‘player-widget-‘ + videoId].on(“error”, playerErrorFn);
}
var playerFinishFn = function (e, api, err) {
var videoAutoSwitchInput = document.getElementById(‘video-auto-switch-input’);
if (!videoAutoSwitchInput) {
console.log(‘video-auto-switch-input is not on this page’);
return;
}
if (!videoAutoSwitchInput.checked) {
console.log(‘video-auto-switch-input is not checked’);
return;
}
var videoAutoWidget = document.getElementById(‘video-auto-widget’);
if (!videoAutoWidget) {
console.log(‘video-auto-widget not on this page’);
return;
}
var videos = videoAutoWidget.querySelectorAll(‘.video-container’);
for (var i = 0 ; i
“,
];
function displayNativeAds() {
googletag.cmd.push(function() { googletag.display(‘div-gpt-ad-1520416573698-0’); });
googletag.cmd.push(function() { googletag.display(‘div-gpt-ad-1520507866383-0’); });
googletag.cmd.push(function() { googletag.display(‘div-gpt-ad-1520507954168-0’); });
}
//to place ads on 3rd, 8th, 13th (and so on) positions
var index = 2;
//generating native Ads div array
var nativeAdsDiv = {};
for(var i=0; i
Be the first to comment