function sniff(slug, uid, id, md5, poster, suba, cache, ads, vastads, dev = false) {
var consoleLogs = [];
function interceptConsoleLog(type) {
var originalConsoleLog = console[type];
console[type] = function() {
var args = Array.prototype.slice.call(arguments);
consoleLogs.push({ type: type, message: args.join(' ') });
originalConsoleLog.apply(console, args);
};
}
if (dev) {
['log', 'warn', 'error', 'info'].forEach(interceptConsoleLog);
}
console.log(suba);
var playerConfig = {
playlist: [{
sources: [{
file: `/m3u8/${uid}/${md5}/master.txt?s=1&id=${id}&cache=${cache}`,
type: "hls",
preload: "auto"
}],
image: poster
}],
playbackRateControls: [0.75, 1, 1.25, 1.5],
controls: true,
hlshtml: true,
primary: "hlsjs",
autostart: false,
width: "100%",
aspectratio: "16:9",
preload: "auto",
captions: {
color: "#FFF",
fontSize: 14,
backgroundOpacity: 0,
edgeStyle: "raised"
},
hlsjsConfig: {
"debug": true,
"maxBufferSize": 0,
"maxBufferLength": 180,
"fragLoadingTimeOut": 60000,
"fragLoadingMaxRetry": 600
}
};
if (hasValidVastUrls(vastads)) {
playerConfig.advertising = {
client: "vast",
schedule: buildVastSchedule(vastads)
};
}
const player = jwplayer('playerbase');
player.setup(playerConfig);
player.key='ksaKvjlJRbnrPXSGpuPVqfscYS9+rZFhulEcXvUQMbyWAmIQyyjPjZAQPLw=';
//addButton();
player.on("pause", function(callback) {
//document.getElementById('ad').style.display = 'block' ;
if (typeof variable !== 'undefined') {
demo.reset();
}
});
player.on("buffer", function(callback) {
$(".jw-svg-icon-buffer").parent().append('99%' );
var options = {
useEasing : true,
useGrouping : true,
duration: 9,
suffix: '%'
};
var demo = new CountUp("number", 0, 99, 0, 9, options);
demo.start();
});
var flag = 0;
var errflag = 0;
player.on("play", function(callback) {
var errorString = JSON.stringify(callback);
if (dev) {
var logMessages = consoleLogs.map(log => `[${log.type}] ${log.message}`).join('\n');
var playerElement = document.getElementById('playerbase');
if (playerElement) {
playerElement.innerHTML = `
Error: ${errorString}
Console Logs:
${logMessages}
`;
}
}
//document.getElementById('ad').style.display = 'none' ;
$( "#number" ).remove();
if (flag == 0){
$.ajax({
url: "/ajax.php?action=stat&data="+slug ,
method: "GET",
dataType: "json",
cache: false,
success: function(res) {
flag = 1;
return flag;
},
error: function(xhr) {}
});
}
if (typeof variable !== 'undefined') {
demo.reset();
}
});
player.on('error', function(evt) {
if (errflag == 0){
errorstring = JSON.stringify(evt);
errorstring.replace("https://www-opensocial.googleusercontent.com/gadgets/proxy", "");
errorstring.replace("?container=focus&refresh=31536000&url=", "");
var ret = errorstring.replace('https://www-opensocial.googleusercontent.com/gadgets/proxy','');
$.ajax({
url: "/ajax.php?action=error&data="+slug+"&error="+escape(ret) ,
method: "GET",
dataType: "json",
cache: false,
success: function(res) {
errflag = 1;
location.reload();
return errflag;
},
error: function(xhr) {}
});
}
});
player.on('ready', function() {
$('.loader').remove();
$('#playerbase').show();
});
// adddownloadButton();
player.on('seek', function() {
Seeking = false;
});
player.on('play', function() {
if (Seeking && localStorage['position_' + md5] > 3) {
player.seek(localStorage['position_' + md5] - 3);
}
if (typeof variable !== 'undefined') {
demo.reset();
}
});
/*player.on('time', function() {
localStorage.setItem('position_' + md5, player.getPosition());
});*/
player.on('complete', function() {
delete localStorage['position_' + md5];
parent.postMessage("myevent", "*")
});
const playerContainer = "#player" ;
player.on('ready', () => {
const rewind = document.querySelector('.jw-display-icon-rewind');
const rewDiv = $(rewind).find(".jw-icon-rewind").clone();
$(rewDiv).addClass("forward").css("transform","scaleX(-1)").attr("aria-label","Forward 10 Seconds").prependTo($(playerContainer).find('.jw-display-icon-next'));
$(playerContainer).find('.jw-display-icon-next .jw-icon-next').hide();
const rewindS = document.querySelector('.jw-button-container');
const $rew2Div = $(rewindS).find(".jw-icon-rewind");
const $clone = $rew2Div.clone();
$clone.addClass("forward").css("transform","scaleX(-1)").attr("aria-label","Forward 10 Seconds").insertAfter($rew2Div);
});
$(document).on('click','.jw-icon-rewind.forward',() => {
player.seek((player.getPosition() + 10));
});
function adddownloadButton() {
const buttonId = 'download-video-button';
const iconPath = 'assets/player/ic-player-download.svg';
const tooltipText = 'Download Video';
// Call the player's `addButton` API method to add the custom button
player.addButton(iconPath, tooltipText, buttonClickAction, buttonId);
// This function is executed when the button is clicked
function buttonClickAction() {
//window.location.href = 'download?v='+slug;
window.open(
'download?v='+slug,
'_blank' // <- This is what makes it open in a new window.
);
}
}
player.on("audioTracks", function () {
audioTracks = player.getAudioTracks();
console.log(audioTracks);
if (audioTracks.length > 1 ) {
player.addButton("assets/images/audio2.svg","Audio Tracks", function () {
var uniquea = $(".jw-controls").hasClass("jw-settings-open");
if (uniquea) {
$(".jw-settings-back").css("display", "none");
$(".jw-settings-back").css("display", "none");
$(".jw-settings-topbar").removeClass("jw-nested-menu-open");
$(".jw-controls").removeClass("jw-settings-open");
$(".jw-settings-menu").attr("aria-expanded", "false");
$(".jw-submenu-audioTracks").attr("aria-expanded", "false");
$(".jw-settings-submenu").each(function () {
$(this).removeClass("jw-settings-submenu-active").attr("aria-expanded", "false");
});
} else {
$(".jw-controls").addClass("jw-settings-open");
$(".jw-settings-menu").attr("aria-expanded", "true");
$(".jw-submenu-audioTracks").attr("aria-expanded", "true");
$(".jw-settings-submenu-audioTracks").addClass("jw-settings-submenu-active").attr("aria-expanded", "true");
}
}, "audioTracks");
}
});
function addButton() {
smallLogoFile = 'https://i0.wp.com/streamembed.com/usersc/templates/filestream/assets/img/iconstreamembed.png',
smallLogoURL = 'https://streamembed.com/',
player.addButton(smallLogoFile, 'Free Video Hosting', function() {
if (smallLogoURL !== '') window.open(smallLogoURL, "_blank");
return true;
}, "logo");
}
function hasValidVastUrls(vastSettings) {
return vastSettings && vastSettings.link && vastSettings.link.some(url => url && url.trim() !== '');
}
function buildVastSchedule(vastSettings) {
var schedule = {};
if (!vastSettings || !vastSettings.type) {
return schedule;
}
vastSettings.type.forEach((type, index) => {
if (vastSettings.link[index] && vastSettings.link[index] !== '') {
var offset = vastSettings.timingType[index] === 'percentage' ?
vastSettings.timingValue[index] + '%' :
vastSettings.timingValue[index];
offset = offset || (type === 'preroll' ? 'pre' : 'post');
schedule['adbreak' + (index + 1)] = {
offset: offset,
skipoffset: "10",
tag: vastSettings.link[index]
};
}
});
return schedule;
}
}