2
0

srs_bwt.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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: 30px;
  10. }
  11. #main_modal {
  12. width: 700px;
  13. margin-left: -350px;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <img src='//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">LivePlayer</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. </ul>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="container">
  38. <div name="detect_flash">
  39. <div id="main_flash_alert" class="alert alert-danger fade in hide">
  40. <button type="button" class="close" data-dismiss="alert">×</button>
  41. <strong><p>Usage:</p></strong>
  42. <p>
  43. 请点击下面的图标,启用Flash
  44. </p>
  45. <p>
  46. 若没有见到这个图标,Chrome浏览器请打开
  47. <span class="text-info">chrome://settings/content/flash</span> 并修改为"Ask first"。
  48. </p>
  49. </div>
  50. <div id="main_flash_hdr" class="hide">
  51. </div>
  52. </div>
  53. <div id="main_content" class="hide">
  54. <div class="alert alert-info fade in">
  55. <button type="button" class="close" data-dismiss="alert">×</button>
  56. <strong><span>Usage:</span></strong> <span>点击“开始测速”即可测带宽,最大可测试带宽由服务器限制</span>
  57. </div>
  58. <div class="form-inline">
  59. URL:
  60. <input type="text" id="txt_url" class="input-xxlarge" value=""></input>
  61. <button class="btn btn-primary" id="btn_play">开始测速</button>
  62. </div>
  63. <div id="main_modal" class="modal hide fade">
  64. <div class="modal-header">
  65. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  66. <h3>SRS Bandwidth Check</h3>
  67. </div>
  68. <div class="modal-body">
  69. <div class="row-fluid">
  70. <div class="span1"></div>
  71. <div class="span10">
  72. <div class="progress progress-striped active" id="pb_buffer_bg">
  73. <div class="bar" style="width: 0%;" id="progress_bar"></div>
  74. </div>
  75. </div>
  76. <div class="span1"></div>
  77. </div>
  78. <div id="check_status">status</div>
  79. <div id="check_info">info</div>
  80. </div>
  81. <div class="modal-footer">
  82. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true"> 关闭 </button>
  83. </div>
  84. </div>
  85. </div>
  86. <footer>
  87. <p></p>
  88. <p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2013</a></p>
  89. </footer>
  90. <div class="container">
  91. <div id="player"></div>
  92. </div>
  93. </div>
  94. </body>
  95. <script type="text/javascript" src="js/jquery-1.12.2.min.js"></script>
  96. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  97. <script type="text/javascript" src="js/swfobject.js"></script>
  98. <script type="text/javascript" src="js/srs.page.js"></script>
  99. <script type="text/javascript" src="js/srs.log.js"></script>
  100. <script type="text/javascript" src="js/srs.player.js"></script>
  101. <script type="text/javascript" src="js/srs.publisher.js"></script>
  102. <script type="text/javascript" src="js/srs.utility.js"></script>
  103. <script type="text/javascript" src="js/winlin.utility.js"></script>
  104. <script type="text/javascript" src="srs_bwt/src/srs.bandwidth.js"></script>
  105. <script type="text/javascript">
  106. var __on_flash_ready = null;
  107. $(function(){
  108. // 探测Flash是否正常启用。
  109. $('#main_flash_hdr').html(
  110. '\
  111. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100%"> \
  112. <param name="movie" value="srs_player/release/srs_player.swf"> \
  113. <param name="quality" value="autohigh"> \
  114. <param name="swliveconnect" value="true"> \
  115. <param name="allowScriptAccess" value="always"> \
  116. <param name="bgcolor" value="#0"> \
  117. <param name="allowFullScreen" value="true"> \
  118. <param name="wmode" value="opaque"> \
  119. <param name="FlashVars" value="log=1"> \
  120. <param name="flashvars" value="id=1&on_player_ready=__on_flash_ready"> \
  121. <embed src="srs_player/release/srs_player.swf" width="100%" height="100%" \
  122. quality="autohigh" bgcolor="#0" align="middle" allowfullscreen="true" allowscriptaccess="always" \
  123. type="application/x-shockwave-flash" swliveconnect="true" wmode="opaque" \
  124. flashvars="id=1&on_player_ready=__on_flash_ready" \
  125. pluginspage="http://www.macromedia.com/go/getflashplayer"> \
  126. </object> \
  127. '
  128. );
  129. $('#main_flash_hdr').show();
  130. var showFlashHdr = setTimeout(function(){
  131. $('#main_flash_alert').show();
  132. }, 300);
  133. __on_flash_ready = function (id) {
  134. clearTimeout(showFlashHdr);
  135. $('#main_flash_alert').hide();
  136. $('#main_flash_hdr').hide();
  137. $('#main_content').show();
  138. autoLoadPage();
  139. };
  140. });
  141. </script>
  142. <script type="text/javascript">
  143. var bandwidth = null;
  144. // for bw to init url
  145. // url: scheme://host:port/path?query#fragment
  146. function srs_init_bwt(rtmp_url, hls_url) {
  147. update_nav();
  148. if (rtmp_url) {
  149. $(rtmp_url).val(build_default_bandwidth_rtmp_url());
  150. }
  151. }
  152. // for the bandwidth tool to init page
  153. function build_default_bandwidth_rtmp_url() {
  154. var query = parse_query_string();
  155. var schema = 'rtmp';
  156. var server = (!query.server)? window.location.hostname:query.server;
  157. var port = (!query.port)? 1935:query.port;
  158. var vhost = "bandcheck.srs.com";
  159. var app = (!query.app)? "app":query.app;
  160. var key = (!query.key)? "35c9b402c12a7246868752e2878f7e0e":query.key;
  161. var uri = schema + "://" + server;
  162. if (!is_default_port(schema, port)) {
  163. uri += ":" + port;
  164. }
  165. uri += "/" + app + "?key=" + key + "&vhost=" + vhost;
  166. return uri;
  167. }
  168. var autoLoadPage = function() {
  169. srs_init_bwt("#txt_url");
  170. $("#btn_play").click(on_click_play);
  171. $("#main_modal").on("show", on_start_bandwidth_test);
  172. $("#main_modal").on("hide", on_stop_bandwidth_test);
  173. };
  174. function on_click_play() {
  175. $("#check_status").text("");
  176. $("#check_info").text("");
  177. $("#progress_bar").width("0%");
  178. $("#main_modal").modal({show:true, keyboard:false});
  179. }
  180. function on_start_bandwidth_test() {
  181. $("#div_container").remove();
  182. $("#progress_bar").removeClass("bar-danger");
  183. var div_container = $("<div/>");
  184. $(div_container).attr("id", "div_container");
  185. $("#player").append(div_container);
  186. var player = $("<div/>");
  187. $(player).attr("id", "player_id");
  188. $(div_container).append(player);
  189. var url = $("#txt_url").val();
  190. bandwidth = new SrsBandwidth("player_id", 100, 1);
  191. bandwidth.on_bandwidth_ready = function() {
  192. this.check_bandwidth(url);
  193. }
  194. bandwidth.on_update_progress = function(percent) {
  195. $("#progress_bar").width(percent + "%");
  196. }
  197. bandwidth.on_update_status = function(status) {
  198. $("#check_status").text(status);
  199. }
  200. bandwidth.on_srs_info = function(srs_server, srs_primary, srs_authors, srs_id, srs_pid, srs_server_ip) {
  201. $("#check_info").text(
  202. "server:" + srs_server + ", srs_id:" + srs_id + ", srs_pid:" + srs_pid + ", ip:" + srs_server_ip
  203. );
  204. }
  205. bandwidth.on_error = function(code) {
  206. $("#progress_bar").addClass("bar-danger");
  207. }
  208. bandwidth.render(url);
  209. }
  210. function on_stop_bandwidth_test() {
  211. bandwidth.stop();
  212. }
  213. </script>
  214. </html>