function addObjEvent(sObj, sEvType, sFunction, sPassive){
if(sObj.attachEvent){
return sObj.attachEvent(‘on’ + sEvType, sFunction);
}else if(sObj.addEventListener){
if(sPassive){
sPassive = pELSupportPassive;
}else{
sPassive = false;
}
sObj.addEventListener(sEvType, sFunction, sPassive);
return true;
}else{
return false;
};
};
function delObjEvent(sObj, sEvType, sFunction){
if(sObj.detachEvent){
return sObj.detachEvent(‘on’ + sEvType, sFunction);
}else if(sObj.removeEventListener){
sObj.removeEventListener(sEvType, sFunction, false);
return true;
}else{
return false;
};
};
function togglePictureInPicture() {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
} else if (document.pictureInPictureEnabled) {
if(
(g_videoHLSLiveGlobal.webkitSupportsPresentationMode)
&&
(typeof g_videoHLSLiveGlobal.webkitSetPresentationMode === “function”))
{
g_videoHLSLiveGlobal.webkitSetPresentationMode(g_videoHLSLiveGlobal.webkitPresentationMode === “picture-in-picture” ? “inline” : “picture-in-picture”);
}
g_videoHLSLiveGlobal.requestPictureInPicture();
} else if(
(g_videoHLSLiveGlobal.webkitSupportsPresentationMode)
&&
(typeof g_videoHLSLiveGlobal.webkitSetPresentationMode === “function”))
{
g_videoHLSLiveGlobal.webkitSetPresentationMode(g_videoHLSLiveGlobal.webkitPresentationMode === “picture-in-picture” ? “inline” : “picture-in-picture”);
}
}
function enterPic(){
console.log(‘enterPic’);
g_videoHLSLiveGlobal.className = ”;
}
function exitPic(){
console.log(‘exitPic’);
g_videoExitPicGlobal = true;
g_videoHLSLiveGlobal.className = ‘show’;
setTimeout(g_videoHLSLiveGlobal.play, 100);
}
function autoPic(){
console.log(‘autoPic’);
if(!(g_videoExitPicGlobal)){
g_videoHLSLiveGlobal.play();
togglePictureInPicture();
}
}
var g_audioLiveGlobal = document.getElementById(‘audioLiveGlobal’);
var g_videoHLSLiveGlobal = document.getElementById(‘videoHLSLiveGlobal’);
var g_iframePlayerBoxGlobal = document.getElementById(‘iframePlayerGlobal’);
var g_iframeTransitionBoxGlobal = document.getElementById(‘iframeTransitionGlobal’);
addObjEvent(g_iframePlayerBoxGlobal, ‘load’, loadNewURLIFrame);
addObjEvent(g_iframePlayerBoxGlobal, ‘unload’, unloadNewURLIFrame);
var g_videoExitPicGlobal = false;
addObjEvent(g_videoHLSLiveGlobal, ‘enterpictureinpicture’, enterPic);
addObjEvent(g_videoHLSLiveGlobal, ‘leavepictureinpicture’, exitPic);
addObjEvent(g_videoHLSLiveGlobal, ‘play’, autoPic);
addObjEvent(g_videoHLSLiveGlobal, ‘loadedmetadata’, autoPic);
function loadNewURLIFrame(){
g_iframePlayerBoxGlobal.className = ‘show’;
g_iframeTransitionBoxGlobal.className = ‘trans_hide’;
setTimeout(function(){
g_iframeTransitionBoxGlobal.className = ‘hide’;
}, 100);
g_iframePlayerBoxGlobal.contentWindow.removeEventListener(“unload”, unloadNewURLIFrame);
g_iframePlayerBoxGlobal.contentWindow.addEventListener(“unload”, unloadNewURLIFrame);
}
function unloadNewURLIFrame(){
g_iframePlayerBoxGlobal.className = ‘no-transition hide’;
console.log(‘###====================================’);
console.log(this.scrollTop);
console.log(g_iframePlayerBoxGlobal.scrollTop);
console.log(g_iframePlayerBoxGlobal.contentDocument.scrollTop);
console.log(g_iframePlayerBoxGlobal.contentDocument.body.scrollTop);
console.log(‘###====================================’);
console.log(g_iframePlayerBoxGlobal.contentWindow.document.body.scrollTop);
console.log(‘###====================================’);
g_iframeTransitionBoxGlobal.innerHTML = g_iframePlayerBoxGlobal.contentDocument.body.outerHTML;
g_iframeTransitionBoxGlobal.scrollTop = g_iframePlayerBoxGlobal.contentDocument.scrollTop;
console.log(g_iframeTransitionBoxGlobal.scrollTop);
g_iframeTransitionBoxGlobal.className = ‘show’;
}
function checkAudioLoad(){
g_audioLiveGlobal.setAttribute(‘poster’, ‘https://mobile.fmodia.com.br/wp-content/uploads/2023/02/cropped-logo-fm-o-dia-topo-1.png’);
g_audioLiveGlobal.setAttribute(‘src’, ‘https://streaming.livespanel.com:20000/live’);
//g_audioLiveGlobal.addEventListener(‘canplay’, function () {
// g_audioLiveGlobal.play();
//});
//if(typeof(g_audioLiveGlobal.stop) == ‘function’) g_audioLiveGlobal.stop();
//return;
//g_audioLiveGlobal.src = ‘https://streaming.livespanel.com:20000/live’;
setTimeout(function(){
g_audioLiveGlobal.className = ‘show’;
g_videoHLSLiveGlobal.className = ”;
}, 100);
g_audioLiveGlobal.addEventListener(‘canplay’, function () {
g_audioLiveGlobal.play();
});
if(typeof(g_videoHLSLiveGlobal.stop) == ‘function’) g_videoHLSLiveGlobal.stop();
}
function checkHLSLoad(){
if(typeof(Hls) == ‘undefined’){
setTimeout(checkHLSLoad, 1000);
}else{
setTimeout(function(){
g_audioLiveGlobal.className = ”;
g_videoHLSLiveGlobal.className = ‘show’;
}, 100);
if (Hls.isSupported()) {
var hls = new Hls({
debug: true,
});
//hls.loadSource(‘https://cdn.livespanel.com/bw-live/adt_fmodia/playlist.m3u8’);
hls.loadSource(‘https://cdn.livespanel.com/live/mobile/playlist.m3u8’);
//hls.loadSource(‘https://cdn.livespanel.com/bw-live/adt_fmodia/playlist.m3u8’);
hls.attachMedia(g_videoHLSLiveGlobal);
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
//g_videoHLSLiveGlobal.muted = true;
g_videoHLSLiveGlobal.play();
});
}
// hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
// When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element through the `src` property.
// This is using the built-in support of the plain video element, without using hls.js.
else if (g_videoHLSLiveGlobal.canPlayType(‘application/vnd.apple.mpegurl’)) {
g_videoHLSLiveGlobal.src = ‘https://cdn.livespanel.com/bw-live/adt_fmodia/playlist.m3u8’;
g_videoHLSLiveGlobal.addEventListener(‘canplay’, function () {
g_videoHLSLiveGlobal.play();
});
}
}
if(typeof(g_audioLiveGlobal.stop) == ‘function’) g_audioLiveGlobal.stop();
}
var tFullHash = decodeURIComponent(location.hash);
console.log(‘===’);
console.log(tFullHash);
var tPlayerType = tFullHash.substr(0, tFullHash.indexOf(‘/’));
var tURIRequest = tFullHash.substr(tFullHash.indexOf(‘/’));
console.log(tPlayerType);
console.log(tURIRequest);
if(tPlayerType == ‘#ouca#’){
//g_iframePlayerBoxGlobal.src = ‘https://mobile.fmodia.com.br’ + tURIRequest;
playAudio();
}else if(tPlayerType == ‘#veja#’){
//g_iframePlayerBoxGlobal.src = ‘https://mobile.fmodia.com.br’ + tURIRequest;
playVideo();
}else{
//g_iframePlayerBoxGlobal.src = ‘https://mobile.fmodia.com.br/ouca’;
//checkAudioLoad();
playVideo();
}
g_iframePlayerBoxGlobal.src = ‘https://mobile.fmodia.com.br’ + tURIRequest;
function stopAudio(){
if(typeof(g_audioLiveGlobal.pause) == ‘function’) g_audioLiveGlobal.pause();
if(typeof(g_videoHLSLiveGlobal.pause) == ‘function’) g_videoHLSLiveGlobal.pause();
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
function stopVideo(){
if(typeof(g_audioLiveGlobal.pause) == ‘function’) g_audioLiveGlobal.pause();
if(typeof(g_videoHLSLiveGlobal.pause) == ‘function’) g_videoHLSLiveGlobal.pause();
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
function playAudio(){
console.log(‘playAudio’);
g_audioLiveGlobal.className = ‘show’;
g_videoHLSLiveGlobal.className = ”;
stopVideo();
checkAudioLoad();
}
function playVideo(){
console.log(‘playVideo’);
g_audioLiveGlobal.className = ”;
g_videoHLSLiveGlobal.className = ‘show’;
stopAudio();
checkHLSLoad();
}
/*
window.onpopstate = function(e){
if(e.state){
//document.getElementById(“content”).innerHTML = e.state.html;
document.title = e.state.pageTitle;
}
};
*/
function setCurrentHead(sInfos){
document.title = sInfos.Title;
window.history.pushState(sInfos, “”, sInfos.URI);
}