2
0

srs_bwt.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>SRS</title>
  5. <meta charset="utf-8">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
  7. <style>
  8. body{
  9. padding-top: 55px;
  10. }
  11. #main_modal {
  12. width: 700px;
  13. margin-left: -350px;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/bwt'/>
  19. <div class="navbar navbar-fixed-top">
  20. <div class="navbar-inner">
  21. <div class="container">
  22. <a id="srs_index" class="brand" href="#">SRS</a>
  23. <div class="nav-collapse collapse">
  24. <ul class="nav">
  25. <li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
  26. <li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
  27. <li><a id="nav_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
  28. <li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
  29. <li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
  30. <li class="active"><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
  31. <li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>
  32. <li><a id="nav_gb28181" href="srs_gb28181.html">SRS-GB28181</a></li>
  33. </ul>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="container">
  39. <div name="detect_flash">
  40. <div id="main_flash_alert" class="alert alert-danger fade in hide">
  41. <button type="button" class="close" data-dismiss="alert">×</button>
  42. <strong><p>Usage:</p></strong>
  43. <p>
  44. 请点击下面的图标,启用Flash
  45. </p>
  46. <p>
  47. 若没有见到这个图标,Chrome浏览器请打开
  48. <span class="text-info">chrome://settings/content/flash</span> 并修改为"Ask first"。
  49. </p>
  50. </div>
  51. <div id="main_flash_hdr" class="hide">
  52. </div>
  53. </div>
  54. <div id="main_content" class="hide">
  55. <div class="alert alert-info fade in">
  56. <button type="button" class="close" data-dismiss="alert">×</button>
  57. <strong><span>Usage:</span></strong> <span>点击“开始测速”即可测带宽,最大可测试带宽由服务器限制</span>
  58. </div>
  59. <div class="form-inline">
  60. URL:
  61. <input type="text" id="txt_url" class="input-xxlarge" value=""></input>
  62. <button class="btn btn-primary" id="btn_play">开始测速</button>
  63. </div>
  64. <div id="main_modal" class="modal hide fade">
  65. <div class="modal-header">
  66. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  67. <h3>SRS Bandwidth Check</h3>
  68. </div>
  69. <div class="modal-body">
  70. <div class="row-fluid">
  71. <div class="span1"></div>
  72. <div class="span10">
  73. <div class="progress progress-striped active" id="pb_buffer_bg">
  74. <div class="bar" style="width: 0%;" id="progress_bar"></div>
  75. </div>
  76. </div>
  77. <div class="span1"></div>
  78. </div>
  79. <div id="check_status">status</div>
  80. <div id="check_info">info</div>
  81. </div>
  82. <div class="modal-footer">
  83. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true"> 关闭 </button>
  84. </div>
  85. </div>
  86. </div>
  87. <footer>
  88. <p></p>
  89. <p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2013</a></p>
  90. </footer>
  91. <div class="container">
  92. <div id="player"></div>
  93. </div>
  94. </div>
  95. </body>
  96. <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
  97. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  98. <script type="text/javascript" src="js/swfobject.js"></script>
  99. <script type="text/javascript" src="js/srs.page.js"></script>
  100. <script type="text/javascript" src="js/srs.log.js"></script>
  101. <script type="text/javascript" src="js/srs.player.js"></script>
  102. <script type="text/javascript" src="js/srs.publisher.js"></script>
  103. <script type="text/javascript" src="js/srs.utility.js"></script>
  104. <script type="text/javascript" src="js/winlin.utility.js"></script>
  105. <script type="text/javascript" src="srs_bwt/src/srs.bandwidth.js"></script>
  106. <script type="text/javascript">
  107. var __on_flash_ready = null;
  108. $(function(){
  109. // 探测Flash是否正常启用。
  110. $('#main_flash_hdr').html(
  111. '\
  112. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100%"> \
  113. <param name="movie" value="srs_player/release/srs_player.swf"> \
  114. <param name="quality" value="autohigh"> \
  115. <param name="swliveconnect" value="true"> \
  116. <param name="allowScriptAccess" value="always"> \
  117. <param name="bgcolor" value="#0"> \
  118. <param name="allowFullScreen" value="true"> \
  119. <param name="wmode" value="opaque"> \
  120. <param name="FlashVars" value="log=1"> \
  121. <param name="flashvars" value="id=1&on_player_ready=__on_flash_ready"> \
  122. <embed src="srs_player/release/srs_player.swf" width="100%" height="100%" \
  123. quality="autohigh" bgcolor="#0" align="middle" allowfullscreen="true" allowscriptaccess="always" \
  124. type="application/x-shockwave-flash" swliveconnect="true" wmode="opaque" \
  125. flashvars="id=1&on_player_ready=__on_flash_ready" \
  126. pluginspage="http://www.macromedia.com/go/getflashplayer"> \
  127. </object> \
  128. '
  129. );
  130. $('#main_flash_hdr').show();
  131. var showFlashHdr = setTimeout(function(){
  132. $('#main_flash_alert').show();
  133. }, 300);
  134. __on_flash_ready = function (id) {
  135. clearTimeout(showFlashHdr);
  136. $('#main_flash_alert').hide();
  137. $('#main_flash_hdr').hide();
  138. $('#main_content').show();
  139. autoLoadPage();
  140. };
  141. });
  142. </script>
  143. <script type="text/javascript">
  144. var bandwidth = null;
  145. var autoLoadPage = function() {
  146. srs_init_bwt("#txt_url");
  147. $("#btn_play").click(on_click_play);
  148. $("#main_modal").on("show", on_start_bandwidth_test);
  149. $("#main_modal").on("hide", on_stop_bandwidth_test);
  150. };
  151. function on_click_play() {
  152. $("#check_status").text("");
  153. $("#check_info").text("");
  154. $("#progress_bar").width("0%");
  155. $("#main_modal").modal({show:true, keyboard:false});
  156. }
  157. function on_start_bandwidth_test() {
  158. $("#div_container").remove();
  159. $("#progress_bar").removeClass("bar-danger");
  160. var div_container = $("<div/>");
  161. $(div_container).attr("id", "div_container");
  162. $("#player").append(div_container);
  163. var player = $("<div/>");
  164. $(player).attr("id", "player_id");
  165. $(div_container).append(player);
  166. var url = $("#txt_url").val();
  167. bandwidth = new SrsBandwidth("player_id", 100, 1);
  168. bandwidth.on_bandwidth_ready = function() {
  169. this.check_bandwidth(url);
  170. }
  171. bandwidth.on_update_progress = function(percent) {
  172. $("#progress_bar").width(percent + "%");
  173. }
  174. bandwidth.on_update_status = function(status) {
  175. $("#check_status").text(status);
  176. }
  177. bandwidth.on_srs_info = function(srs_server, srs_primary, srs_authors, srs_id, srs_pid, srs_server_ip) {
  178. $("#check_info").text(
  179. "server:" + srs_server + ", srs_id:" + srs_id + ", srs_pid:" + srs_pid + ", ip:" + srs_server_ip
  180. );
  181. }
  182. bandwidth.on_error = function(code) {
  183. $("#progress_bar").addClass("bar-danger");
  184. }
  185. bandwidth.render(url);
  186. }
  187. function on_stop_bandwidth_test() {
  188. bandwidth.stop();
  189. }
  190. </script>
  191. </html>