2
0

srs_bwt.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. <div class="navbar navbar-fixed-top">
  19. <div class="navbar-inner">
  20. <div class="container">
  21. <a id="srs_index" class="brand" href="#">SRS</a>
  22. <div class="nav-collapse collapse">
  23. <ul class="nav">
  24. <li><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
  25. <li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
  26. <li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
  27. <li class="active"><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
  28. <li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
  29. <li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
  30. <li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>
  31. </ul>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="container">
  37. <div class="alert alert-info fade in">
  38. <button type="button" class="close" data-dismiss="alert">×</button>
  39. <strong><span>Usage:</span></strong> <span>点击“开始测速”即可测带宽,最大可测试带宽由服务器限制</span>
  40. </div>
  41. <div class="form-inline">
  42. URL:
  43. <input type="text" id="txt_url" class="input-xxlarge" value=""></input>
  44. <button class="btn btn-primary" id="btn_play">开始测速</button>
  45. </div>
  46. <div id="main_modal" class="modal hide fade">
  47. <div class="modal-header">
  48. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  49. <h3>SRS Bandwidth Check</h3>
  50. </div>
  51. <div class="modal-body">
  52. <div class="row-fluid">
  53. <div class="span1"></div>
  54. <div class="span10">
  55. <div class="progress progress-striped active" id="pb_buffer_bg">
  56. <div class="bar" style="width: 0%;" id="progress_bar"></div>
  57. </div>
  58. </div>
  59. <div class="span1"></div>
  60. </div>
  61. <div id="check_status">status</div>
  62. <div id="check_info">info</div>
  63. </div>
  64. <div class="modal-footer">
  65. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true"> 关闭 </button>
  66. </div>
  67. </div>
  68. <hr>
  69. <footer>
  70. <p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2013</a></p>
  71. </footer>
  72. <div class="container">
  73. <div id="player"></div>
  74. </div>
  75. </div>
  76. </body>
  77. <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
  78. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  79. <script type="text/javascript" src="js/swfobject.js"></script>
  80. <script type="text/javascript" src="js/srs.page.js"></script>
  81. <script type="text/javascript" src="js/srs.log.js"></script>
  82. <script type="text/javascript" src="js/srs.player.js"></script>
  83. <script type="text/javascript" src="js/srs.publisher.js"></script>
  84. <script type="text/javascript" src="js/srs.utility.js"></script>
  85. <script type="text/javascript" src="js/winlin.utility.js"></script>
  86. <script type="text/javascript" src="srs_bwt/src/srs.bandwidth.js"></script>
  87. <script type="text/javascript">
  88. var bandwidth = null;
  89. $(function(){
  90. srs_init_bwt("#txt_url");
  91. $("#btn_play").click(on_click_play);
  92. $("#main_modal").on("show", on_start_bandwidth_test);
  93. $("#main_modal").on("hide", on_stop_bandwidth_test);
  94. });
  95. function on_click_play() {
  96. $("#check_status").text("");
  97. $("#check_info").text("");
  98. $("#progress_bar").width("0%");
  99. $("#main_modal").modal({show:true, keyboard:false});
  100. }
  101. function on_start_bandwidth_test() {
  102. $("#div_container").remove();
  103. $("#progress_bar").removeClass("bar-danger");
  104. var div_container = $("<div/>");
  105. $(div_container).attr("id", "div_container");
  106. $("#player").append(div_container);
  107. var player = $("<div/>");
  108. $(player).attr("id", "player_id");
  109. $(div_container).append(player);
  110. var url = $("#txt_url").val();
  111. bandwidth = new SrsBandwidth("player_id", 100, 1);
  112. bandwidth.on_bandwidth_ready = function() {
  113. this.check_bandwidth(url);
  114. }
  115. bandwidth.on_update_progress = function(percent) {
  116. $("#progress_bar").width(percent + "%");
  117. }
  118. bandwidth.on_update_status = function(status) {
  119. $("#check_status").text(status);
  120. }
  121. bandwidth.on_srs_info = function(srs_server, srs_primary, srs_authors, srs_id, srs_pid, srs_server_ip) {
  122. $("#check_info").text(
  123. "server:" + srs_server + ", primary:" + srs_primary + ", authors:" + srs_authors +
  124. ", srs_id:" + srs_id + ", srs_pid:" + srs_pid + ", ip:" + srs_server_ip
  125. );
  126. }
  127. bandwidth.on_error = function(code) {
  128. $("#progress_bar").addClass("bar-danger");
  129. }
  130. bandwidth.render(url);
  131. }
  132. function on_stop_bandwidth_test() {
  133. bandwidth.stop();
  134. }
  135. </script>
  136. </html>