var body = document.documentElement || document.body;
var playlistThree = [{
"file": "https://ir14.livekadeh.com/hls2/Gtv.m3u8",
"image":"images (4).jpeg",
"title": "Gtv"
}];
const username = "Gtv";
//load info.json to localstroge
dl_Storage("/official/Gtv/info.json");
var urlplayeriran = "https://ir14.livekadeh.com/hls2/Gtv.m3u8";
var urlplayergr = "//nl.livekadeh.com/hls2/Gtv.m3u8";
var player = jwplayer("myElement");
var in_hlslabels;
player.setup({
logo: {
file: "/jw8/logo.png",
link: "https://livekadeh.com/"
},
image: "images (4).jpeg",
"playlist": playlistThree,
preload: "auto",
width: body.clientWidth,
repeat: true,
mute: false,
autostart:true,
androidhls: true,
//stretching: "none",
renderCaptionsNatively:false,
height: body.clientHeight-30,
floating: true,
intl: {
// Quebec french sub-block
en: {
play: "Play",
liveBroadcast: "Live"
}
}
});
//jwplayer().load(playlistThree);
//if (error = "ENOENT") {window.location.replace("/404.html");}
function loadplayer (){
player.on('ready',function() {
//jwplayer("myElement").setFullscreen(true);
player.play();
});
}
function resize() {
//document.getElementsByTagName("cloudflare-app")[0].style.margin = "0 0 0 0";
var w = window.innerWidth;
var h = window.innerHeight;
//jwplayer("myElement").setFullscreen(true);
player.resize(body.clientWidth, body.clientHeight);
if (w <=193 ){
document.getElementById('online-visitors-counter').style.display = "none";
document.getElementById('chat-area').style.display = "none";
document.getElementById('sendie').style.display = "none";
}
//var txt = "Window size: width=" + w + ", height=" + h;
//document.getElementById("demo").innerHTML = txt;
}
//run player
loadplayer();
window.onload = function () {
document.getElementsByTagName("cloudflare-app")[0].style.margin = "0 0 0 0";
player.resize(body.clientWidth, body.clientHeight);
document.getElementsByClassName("jw-svg-icon jw-svg-icon-cc-off")[0].style.display="none";
document.getElementsByClassName("jw-reset jw-settings-menu")[0].style.display="none";
}
player.on('error', function(evt){
var element = document.getElementById("myElement");
console.log(evt);
// echo_log(evt.message);
if (evt.message === "Casting failed to load" ||evt.message === "Captions renderer failed to load") {
//element.innerHTML = "
Your message
";
}
//else if(evt.message == "Cannot load M3U8: Crossdomain access denied" || evt.message == "Error loading media: File could not be played" || evt.message == "Cannot load M3U8: 404 Not Found" || evt.message == "The live stream is either down or has ended") {
else{
element.innerHTML = ' در حال انتقال به حالت آفلاین
';
var local_info = localStorage_paras ("info.json");
//console.log(local_info.offlinetype);
//check player is live !
setInterval( log1,5000);
switch(local_info.offlinetype) {
case "pic":
var g=document.createElement('div');g.setAttribute("id", "main");document.body.appendChild(g);
var my_elem = document.getElementById('myElement');
my_elem.parentNode.insertBefore(g, my_elem);
if ( local_info.offlinename != null ){document.getElementById("main").innerHTML = '
';
}else {document.getElementById("main").innerHTML = '
';}
// centerImage("img1");
centerImage("img2");
break;
case "lastvideo":
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//var obj = JSON.parse(this.responseText);
if (this.responseText == "no_video"){
var g=document.createElement('div');g.setAttribute("id", "main");document.body.appendChild(g);
var my_elem = document.getElementById('myElement');
my_elem.parentNode.insertBefore(g, my_elem);
if ( local_info.offlinename != null ){document.getElementById("main").innerHTML = '
';
}else {document.getElementById("main").innerHTML = '
';}
// centerImage("img1");
centerImage("img2");
} else{
if(local_info.logo == 1){logo_link= "";}else{ logo_link= "/jw8/logo_playback.png";}
var playlistThree = [{
"file": this.responseText,
"image":"7.jpg",
"title": "سرور ایران"
}];
var player = jwplayer("myElement");
player.setup({
logo: {
file: logo_link,
link: "https://livekadeh.com/"
},
image: "7.jpg",
"playlist": playlistThree,
preload: "auto",
width: body.clientWidth,
repeat: true,
mute: false,
autostart:true,
androidhls: true,
renderCaptionsNatively:false,
height: body.clientHeight,
cast:{}
});
loadplayer();
}
}
};
xhttp.open("GET", "//ir11.livekadeh.com/admin/lastvideo.php?username="+local_info.username, true);
xhttp.send();
resize();
break;
default:
text = "Looking forward to the Weekend";
}
}
});
/* Notification.requestPermission().then(function(result) {
console.log(result);
}); */
window.onresize = window.onload = function()
{
resize();
}
function centerImage(id)
{
var img = document.getElementById(id);
winDim = getWinDim();
img.style.height = winDim.y + "px";
if (img.offsetWidth > winDim.x)
{
img.style.height = null;
img.style.width = winDim.x + "px";
}
}
function getWinDim()
{
var body = document.documentElement || document.body;
return {
x: window.innerWidth || body.clientWidth,
y: window.innerHeight || body.clientHeight
}
}
//check player is live !
function log1 (){
checkUrl2(urlplayeriran,log2);
}
function log2 (stat){
//console.log(stat);
if (stat == 200) {
//showNotification();
location.reload();
}
}
/* function startPattern() {
// Values at even indices (0, 2, 4, ...) specify vibrations, while the odd
// indices specify pauses.
// Vibrate for 500ms 6 times, pausing for 250ms in between each one.
navigator.vibrate([100,200,100,100,75,25,100,200,100,500,100,200,100,500]);
} */
if ('serviceWorker' in navigator){
navigator.serviceWorker.register('sw.js').then(function(registration){
console.log('service worker registration succeeded:',registration);
},
function(error){
console.log('service worker registration failed:',error);
});
}
else{
console.log('service workers are not supported.');
}
//navigator.serviceWorker.register('sw.js');
function showNotification() {
Notification.requestPermission(function(result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function(registration) {
var options = {
body: "این پخش زنده در دسترس قرار گرفت و صفحه مربوطه بعد از چند ثانیه بروزرسانی میشود.",
icon: "/pic/live21.70x70.png",
vibrate: [300, 100, 300, 100, 300, 100, 300],
tag: 'شروع پخش زنده',
requireInteraction: false,
badge:"https://sport.live21.ir/pic/11.png"
};
registration.showNotification('multilive.ir',options );
});
}
});
}
//navigator.serviceWorker.register('sw.js');
//load info.json to localstroge
// dl_Storage("/official/"+username+"/info.json");
/*
player.on('error', function(evt) {
var local_info = localStorage_paras ("info.json");
//console.log(local_info);
//check player is live !
setInterval( log1,3000);
switch(local_info.offlinetype) {
case "pic":
var g=document.createElement('div');g.setAttribute("id", "main");document.body.appendChild(g);
var my_elem = document.getElementById('myElement');
my_elem.parentNode.insertBefore(g, my_elem);
if (evt.message == "Cannot load M3U8: Crossdomain access denied" && local_info.offlinename != null ){document.getElementById("main").innerHTML = '
';
}else {document.getElementById("main").innerHTML = '
';}
break;
case "lastvideo":
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//var obj = JSON.parse(this.responseText);
var playlistThree = [{
"file": this.responseText,
"image":"7.jpg",
"title": "سرور ایران"
}];
var player = jwplayer("myElement");
player.setup({
logo: {
file: "logo.png",
link: "https://livekadeh.com/"
},
image: "7.jpg",
"playlist": playlistThree,
preload: "auto",
width: window.innerWidth,
repeat: true,
mute: false,
autostart:true,
androidhls: true,
height: window.innerHeight ,
cast:{}
});
loadplayer();
}
};
xhttp.open("GET", "//ir11.livekadeh.com/admin/lastvideo.php?username="+local_info.username, true);
xhttp.send();
break;
default:
text = "Looking forward to the Weekend";
}
});
// Also load custom video file on buffer
/* player.on('buffer', function() {
theTimeout = setTimeout(function() {
player.play();
}, 1000);
});
player.on('play', function() {
clearTimeout(theTimeout);
}); */
//get value from localStorage
function localStorage_paras (name){
var lo_st = localStorage.getItem(name);
return JSON.parse(lo_st);
}
function checkUrl2(url,callback) {
/* fetch(url).then(function(response) {
console.log(">>>>"+response+"<<<<<");
}) */
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 ) {
//if(this.status == 410 ) {window.location = "https://multilive.ir/410.html";}
//if(this.status == 404 ) {window.location = "https://multilive.ir/404.html";}
callback(this.status);
//return this.status;
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
function checkUrl(url) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
//console.log(this.readyState);
if (this.readyState == 4 ) {
if(this.status == 410 ) {window.location = "https://ir2.multilive.ir/410.html";}
//if(this.status == 0 ) {window.location = "https://ir2.multilive.ir/411.html";}
//if(this.status == 404 ) {window.location = "https://multilive.ir/404.html";}
console.log(">>>>>"+this.status);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
function echo_log(message) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
};
xhttp.open("GET", 'http://nl2.livekadeh.com:8090/telegram/echo?massege='+message, true);
xhttp.send();
}
//checkUrl(link);