<!doctype html> <html> <head> <meta charset="utf-8"> <script type='text/javascript' src='//code.jquery.com/jquery-1.10.2.js'></script> <script type="text/javascript"> function isUrlExists(url) { setTimeout(isUrlExists, 30000); url = 'http://yourfmsdomain/livepkgrstatus/livestream1.html'; var liveState = document.getElementById('livePlayer').src; var offlineState = document.getElementById('livePlayer').src; var isLive; var isOffline; $.getJSON("http://query.yahooapis.com/v1/public/yql?" + "q=select%20*%20from%20html%20where%20url%3D%22" + encodeURIComponent(url) + "%22&format=json'&callback=?", function (data) { if (data.results[0]) { isLive = 'LIVE'; // alert('Status file exsits! State of stream is: ' + isLive + ' & State of player is: ' + liveState); } else { isOffline = 'OFFLINE'; // alert('Status file does not exist! State of stream is: ' + isOffline + ' & State of player is: ' + offlineState); } if (isLive !== undefined && liveState == 'http://www.yourwebserver.com/channel/flashplayerlive.html') { // alert('no live state change'); } else { if (isLive === undefined) { // alert('state change remove live player'); // code here to phsycially remove element or object } else { // alert('state change refresh live player'); go('http://www.yourwebserver.com/channel/flashplayerlive.html'); } } if (isOffline !== undefined && offlineState == 'http://www.yourwebserver.com/channel/flashplayeroffline.html') { // alert('no offline state change'); } else { if (isOffline === undefined) { // alert('state change remove offline player'); // code here to physically remove element or object } else { // alert('state change refresh offline player'); go('http://www.yourwebserver.com/channel/flashplayeroffline.html'); } } }); } function go(loc){ document.getElementById('livePlayer').src = loc; } $(function () { isUrlExists('http://yourfmsdomain/livepkgrstatus/livestream1.html'); }); </script> </head> <body> <iframe id="livePlayer" src="" width="100%" height="520" frameborder="0" scrolling="no"></iframe> </body> </html> |