function sniff(slug,uid,md5,poster,suba,cache,ads,autostart) { //var hls = new Hls(); console.log(suba); var cdnplayerurl= location.hostname; var bShow = false, Seeking = true; var slug = slug; var cache = cache; var autostart = autostart; //var engine = new p2pml.hlsjs.Engine(); // Setup the player const player = jwplayer('playerbase'); player.setup ( { playlist: [ { sources: [ { file: "/m3u8/"+uid+"/" +md5 + "/master.txt?s=1&cache="+cache+"", type: "hls", preload: "auto" } ], image: poster, tracks: suba } ], /*skin: { name: 'Netflix', },*/ playbackRateControls: [0.75, 1, 1.25, 1.5], controls: true, hlshtml: true, primary: "hlsjs", autostart: autostart, width:"100%", aspectratio:"16:9", preload: "auto", captions: { color: "#FFF", fontSize: 14, backgroundOpacity: 0, edgeStyle: "raised" }, hlsjsConfig: { "debug": true , //"fLoader": class pLoader extends Hls.DefaultConfig.loader { } , "maxBufferSize": 0, "maxBufferLength": 180, "fragLoadingTimeOut": 60000, "fragLoadingMaxRetry": 600, } }); 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) { //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"); } }