Advertisement
qiwichupa

Cybergame/Twitch html

Feb 8th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.00 KB | None | 0 0
  1. <?php
  2. $cg_channel = "qiwichupa";
  3. $tw_channel = "ultimate_game_challenge";
  4.  
  5. #
  6. #   GET CYBERGAME JSON
  7. #
  8. $cg_url="http://api.cybergame.tv/w/streams2.php?channel=$cg_channel";
  9. $cg_json = file_get_contents ($cg_url);
  10. $cg_json_obj = json_decode($cg_json);
  11. $cg_channel_status = $cg_json_obj->online; #0 - offline, 1 - online
  12.  
  13. #
  14. #   GET TWITCH JSON
  15. #
  16.  
  17. $tw_url = "https://api.twitch.tv/kraken/channels/$tw_channel";
  18. $tw_json = file_get_contents ($tw_url);
  19. $tw_json_obj = json_decode($tw_json);
  20. $tw_dash = $tw_json_obj->status;
  21.  
  22.  
  23. #
  24. #       SET CHAT FRAME
  25. #
  26. $chat_iframe = <<<HERE
  27. <div id="chat_wrapper">
  28.         <iframe id="chat_embed" src="http://twitch.tv/chat/embed?channel=$tw_channel&amp;popout_chat=true" style="min-height: 400px; height: 100%; overflow: hidden;"
  29.  
  30. height="500" width="300" frameborder="0" scrolling="no"></iframe>
  31. </div>
  32. HERE;
  33.  
  34. #
  35. #   SET DASH
  36. #
  37.  
  38. $dash = <<<HERE
  39. <div id="dash">
  40. $tw_dash
  41. </div>
  42. HERE;
  43.  
  44.  
  45. #
  46. #       CHOOSE STREAM FRAME
  47. #
  48.     if ($cg_channel_status == 0){
  49. $player_iframe = <<<HERE
  50. <div id="stream_wrapper">
  51.     <object id="live_embed_player_flash" style='height:100%;width:100%' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" bgcolor="#000000">
  52.         <param name="allowFullScreen" value="true">
  53.         <param name="allowScriptAccess" value="always">
  54.         <param name="allowNetworking" value="all">
  55.         <param name="flashvars" value="hostname=www.twitch.tv&amp;channel=krakenslair&amp;auto_play=true&amp;start_volume=25">
  56.         <param name="src" value="http://www.twitch.tv/widgets/live_embed_player.swf?channel=$tw_channel">
  57.         <param name="allowfullscreen" value="true">
  58.         <param name="allowscriptaccess" value="always">
  59.         <param name="allownetworking" value="all">
  60.         <embed id="live_embed_player_flash" style='height:100%;width:100%' type="application/x-shockwave-flash" src="http://www.twitch.tv/widgets/live_embed_player.swf?channel=$tw_channel" allowfullscreen="true" allowscriptaccess="always" allownetworking="all" flashvars="hostname=www.twitch.tv&amp;channel=$tw_channel&amp;auto_play=true&amp;start_volume=25" bgcolor="#000000">
  61.     </object>
  62. </div>
  63.  
  64. HERE;
  65.  
  66.     }else{
  67.  
  68. $player_iframe = <<<HERE
  69. <div id="stream_wrapper">
  70.         <iframe src="http://api.cybergame.tv/p/embed.php?c=$cg_channel&w=100pc&h=100pc&type=embed" width="100%" height="100%" frameborder="0"></iframe>
  71. </div>
  72. HERE;
  73.     }
  74.  
  75.  
  76. #
  77. #       SET HEADER
  78. #
  79.  
  80.  
  81. $header =<<<HERE
  82. <html>
  83. <head>
  84.  
  85. <style>
  86.         html, body { margin: 0px; padding: 0px; }
  87.         #chat_wrapper {
  88.             position: absolute;
  89.             top: 0px;
  90.             bottom: 0px;
  91.             right: 0px;
  92.             left: auto;
  93.             width: 300px;
  94.             height: 100%;
  95.         overflow: hidden;
  96.         }
  97.         #stream_wrapper {
  98.         height: 100%;
  99.     }
  100.     #dash {
  101.         font-size: 16px;
  102.         background-color: #000000;
  103.         color: #ffffff;
  104.     }
  105. </style>
  106.  
  107.  
  108. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js?ver=1.8.3"></script>
  109. <script type="text/javascript">
  110.         function getSize()
  111.         {
  112.             var viewportWidth = document.documentElement.clientWidth, viewportHeight = document.documentElement.clientHeight;
  113.  
  114.             return [viewportWidth, viewportHeight];
  115.         }
  116.         function resizePlayer()
  117.         {
  118.             jQuery('#stream_wrapper').css({
  119.                         'width': (getSize()[0] - 300) + 'px',
  120.                         'height': getSize()[1] + 'px'
  121.                     }
  122.             );
  123.         }
  124.         jQuery(window).load(function(){
  125.             resizePlayer();
  126.             jQuery(window).resize(function() {
  127.                 resizePlayer();
  128.             });
  129.         });
  130.  
  131. </script>
  132.  
  133. <title>
  134. $tw_dash
  135. </title>
  136. </head>
  137. <body>
  138.  
  139. HERE;
  140.  
  141. #
  142. #   SER FOOTER
  143. #
  144.  
  145. $footer= <<<HERE
  146. </body>
  147. </html>
  148.  
  149. HERE;
  150.  
  151.  
  152.  
  153. #
  154. #   CREATE PAGE
  155. #
  156.  
  157. echo $header;
  158. #echo $dash;
  159. echo $chat_iframe;
  160. echo $player_iframe;
  161. echo $footer
  162.  
  163. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement