문제

The below script polls a wowza video server and returns True or False based on if it is live or not.

<script type="text/javascript" src="http://***/system/misc/scripts/streaminformation.js.php?id=36"></script>
<script>document.write(StreamInformation.STREAMSTATUS())</script>

instead of "True" or "False" i would like to embed "On Air" or "Off Air". Problem is i don't have access to the streaminformation.js.php file so i need to do an if statement or something in javascript based on the true or false result received?

I tried running an if statement in php based on the script result but that didn't seem to work

please help

도움이 되었습니까?

해결책

You can't check the result from the Javascript in PHP, because the PHP code runs before the page is sent from the server, and the Javascript runs after the page has arrived to the browser.

Use Javascript to check the result from the script:

<script type="text/javascript">
if (StreamInformation.STREAMSTATUS() == "True") {
  document.write("On Air");
} else {
  document.write("Off Air");
}
</script>

Note: I assumed from the text in your question that the STREAMSTATUS method returns the string "True" when the server is live.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top