stream_viewers.html 1.2 KB

1234567891011121314151617181920212223242526
  1. <div id="bx-stream-viewers-__suffix__" class="bx-stream-viewers">__viewers__</div>
  2. <script>
  3. var fFunc = function () {
  4. let playerInstance = typeof(OvenPlayer) === 'undefined' ? false : OvenPlayer.getPlayerByContainerId("bx-stream-player-__suffix__");
  5. if ((!playerInstance || 'playing' == playerInstance.getState() || 'idle' == playerInstance.getState()) && ('undefined' !== typeof(document.hidden) && !document.hidden)) {
  6. $.getJSON('__url__', function (oData) {
  7. if ('undefined' !== typeof(oData.viewers)) {
  8. $('#bx-stream-viewers-__suffix__').html(oData.viewers);
  9. }
  10. if ('undefined' !== typeof(oData.num) && false !== oData.num) {
  11. $('#bx-stream-processing').hide();
  12. $('.bx-stream-badge').show();
  13. }
  14. if ('undefined' !== typeof(oData.num) && false === oData.num) {
  15. $('.bx-stream-badge').hide();
  16. }
  17. }).always(function() {
  18. setTimeout(fFunc, 3000);
  19. });
  20. }
  21. else {
  22. setTimeout(fFunc, 3000);
  23. }
  24. }
  25. fFunc();
  26. </script>