2
0

whep.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>SRS</title>
  5. <meta charset="utf-8">
  6. <style>
  7. body{
  8. padding-top: 30px;
  9. }
  10. </style>
  11. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
  12. <script type="text/javascript" src="js/jquery-1.12.2.min.js"></script>
  13. <script type="text/javascript" src="js/adapter-7.4.0.min.js"></script>
  14. <script type="text/javascript" src="js/srs.sdk.js"></script>
  15. <script type="text/javascript" src="js/winlin.utility.js"></script>
  16. <script type="text/javascript" src="js/srs.page.js"></script>
  17. </head>
  18. <body>
  19. <img style="width: 0px; height: 0px;" src='//ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/rtcpublisher'/>
  20. <div class="navbar navbar-fixed-top">
  21. <div class="navbar-inner">
  22. <div class="container">
  23. <a class="brand" href="https://github.com/ossrs/srs" target="_blank">SRS</a>
  24. <div class="nav-collapse collapse">
  25. <ul class="nav">
  26. <li><a id="nav_srs_player" href="srs_player.html">LivePlayer</a></li>
  27. <!--<li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>-->
  28. <!--<li><a id="nav_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>-->
  29. <li><a id="nav_whip" href="whip.html">WHIP</a></li>
  30. <li class="active"><a id="nav_whep" href="whip.html">WHEP</a></li>
  31. <li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</a></li>
  32. <!--<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>-->
  33. <!--<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>-->
  34. <!--<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>-->
  35. <!--<li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>-->
  36. <!--<li><a id="nav_gb28181" href="srs_gb28181.html">GB28181</a></li>-->
  37. <!--<li>
  38. <a href="https://github.com/ossrs/srs">
  39. <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
  40. </a>
  41. </li>-->
  42. </ul>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="container">
  48. <div id="main_info" class="alert alert-info fade in">
  49. <button type="button" class="close" data-dismiss="alert">×</button>
  50. <strong><span>Usage:</span></strong> <span>Enter the WebRTC WHEP URL and click "Play" to start playing.</span>
  51. </div>
  52. <div class="form-inline">
  53. URL:
  54. <input type="text" id="txt_url" class="input-xxlarge" value="">
  55. <button class="btn btn-primary" id="btn_play">Play</button>
  56. </div>
  57. <p></p>
  58. <video id="rtc_media_player" controls autoplay></video>
  59. <p></p>
  60. <div class="form-inline">
  61. Controls:
  62. <label>
  63. <input type="checkbox" id="ch_videoonly" style="margin-bottom: 8px"> Video Only
  64. </label>
  65. <label>
  66. <input type="checkbox" id="ch_audioonly" style="margin-bottom: 8px"> Audio Only
  67. </label>
  68. </div>
  69. SessionID: <span id='sessionid'></span>
  70. <p></p>
  71. Simulator: <a href='#' id='simulator-drop'>Drop</a>
  72. <footer>
  73. <p></p>
  74. <p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2020</a></p>
  75. </footer>
  76. </div>
  77. <script type="text/javascript">
  78. $(function(){
  79. var sdk = null; // Global handler to do cleanup when republishing.
  80. var startPlay = function() {
  81. $('#rtc_media_player').show();
  82. // Close PC when user replay.
  83. if (sdk) {
  84. sdk.close();
  85. }
  86. sdk = new SrsRtcWhipWhepAsync();
  87. // User should set the stream when publish is done, @see https://webrtc.org/getting-started/media-devices
  88. // However SRS SDK provides a consist API like https://webrtc.org/getting-started/remote-streams
  89. $('#rtc_media_player').prop('srcObject', sdk.stream);
  90. // Optional callback, SDK will add track to stream.
  91. // sdk.ontrack = function (event) { console.log('Got track', event); sdk.stream.addTrack(event.track); };
  92. // For example: webrtc://r.ossrs.net/live/livestream
  93. var url = $("#txt_url").val();
  94. sdk.play(url, {
  95. videoOnly: $('#ch_videoonly').prop('checked'),
  96. audioOnly: $('#ch_audioonly').prop('checked'),
  97. }).then(function(session){
  98. $('#sessionid').html(session.sessionid);
  99. $('#simulator-drop').attr('href', session.simulator + '?drop=1&username=' + session.sessionid);
  100. }).catch(function (reason) {
  101. sdk.close();
  102. $('#rtc_media_player').hide();
  103. console.error(reason);
  104. });
  105. };
  106. $('#rtc_media_player').hide();
  107. var query = parse_query_string();
  108. srs_init_whep("#txt_url", query);
  109. $("#btn_play").click(startPlay);
  110. // Never play util windows loaded @see https://github.com/ossrs/srs/issues/2732
  111. if (query.autostart === 'true') {
  112. $('#rtc_media_player').prop('muted', true);
  113. console.warn('For autostart, we should mute it, see https://www.jianshu.com/p/c3c6944eed5a ' +
  114. 'or https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#audiovideo_elements');
  115. window.addEventListener("load", function(){ startPlay(); });
  116. }
  117. });
  118. </script>
  119. </body>
  120. </html>