123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>SRS</title>
- <meta charset="utf-8">
- <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
- <style>
- body{
- padding-top: 55px;
- }
- #my_modal_footer {
- margin-top: -20px;
- padding-top: 3px;
- }
- #main_modal {
- margin-top: -60px;
- }
- .div_play_time {
- margin-top: 10px;
- }
- #pb_buffer_bg {
- margin-top: -4px;
- margin-bottom: 10px;
- }
- </style>
- </head>
- <body>
- <img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/srsplayer'/>
- <div class="navbar navbar-fixed-top">
- <div class="navbar-inner">
- <div class="container">
- <a id="srs_index" class="brand" href="#">SRS</a>
- <div class="nav-collapse collapse">
- <ul class="nav">
- <li class="active"><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
- <li><a id="nav_rtc_player" href="rtc_player.html">RTC播放器</a></li>
- <li><a id="nav_rtc_publisher" href="rtc_publisher.html">RTC推流</a></li>
- <li><a href="http://ossrs.net/srs.release/releases/app.html">iOS/Andriod</a></li>
- <!--<li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>-->
- <!--<li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>-->
- <!--<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>-->
- <!--li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>-->
- <li><a id="nav_gb28181" href="srs_gb28181.html">GB28181</a></li>
- <li>
- <a href="https://github.com/ossrs/srs">
- <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
- </a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- <div class="container">
- <div id="main_content">
- <div id="main_info" class="alert alert-info fade in">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <strong><span>Usage:</span></strong> <span>输入HTTP-FLV/HLS地址后点击“播放视频”即可播放视频</span>
- </div>
- <div class="form-inline">
- <div>
- URL:
- <input type="text" id="txt_url" class="input-xxlarge" value="">
- <button class="btn btn-primary" id="btn_play">播放视频</button>
- </div>
- <p></p>
- <div>
- <video id="video_player" width="100%" autoplay controls></video>
- </div>
- <p>
- 分享:<a href="#" id="link_url" target="_blank">请右键拷贝此链接</a>
- </p>
- <div id="main_tips">
- <p></p>
- <p>
- 推荐的其他播放器:
- <ul>
- <li><a href="http://bilibili.github.io/flv.js/demo">flv.js</a>,H5/MSE播放HTTP-FLV</li>
- <li><a href="https://hls-js.netlify.com/demo">hls.js</a>,H5/MSE播放HLS</li>
- <li><a href="http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html">dash.js</a>,H5/MSE播放MPEG-DASH</li>
- </ul>
- </p>
- </div>
- </div>
- </div>
- <div name="detect_flash">
- <div id="main_flash_alert" class="alert alert-danger fade in hide">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <p>
- <a href="https://www.adobe.com/products/flashplayer/end-of-life.html" target="_blank">Flash已死</a>,
- 无法播放RTMP流,可用VLC播放器播放。
- </p>
- <ul>
- <li>若希望做低延迟直播(3-5秒),可用HTTP-FLV,播放器用<a href="http://bilibili.github.io/flv.js/demo">flv.js</a>,H5/MSE播放HTTP-FLV</li>
- <li>若对延迟不敏感(5-10秒),跨平台比较好,可用HLS,播放器用<a href="https://hls-js.netlify.com/demo">hls.js</a>,H5/MSE播放HLS</li>
- <li>若希望超低延迟(1秒内),只需要支持主流的浏览器,可用WebRTC,播放器用<a href="rtc_player.html">RTC播放器</a></li>
- </ul>
- <p>
- 更多信息,参考<a href="https://mp.weixin.qq.com/s/oYn5q4fF9afaged23Ueudg" target="_blank">没有Flash如何做直播?</a>
- </p>
- </div>
- </div>
- <footer>
- <p></p>
- <p><a href="https://github.com/ossrs/srs">SRS Team © 2013</a></p>
- </footer>
- </div>
- </body>
- <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
- <script type="text/javascript" src="js/bootstrap.min.js"></script>
- <script type="text/javascript" src="js/flv-1.5.0.min.js"></script>
- <script type="text/javascript" src="js/hls-0.14.17.min.js"></script>
- <script type="text/javascript" src="js/json2.js"></script>
- <script type="text/javascript" src="js/srs.page.js"></script>
- <script type="text/javascript" src="js/srs.log.js"></script>
- <script type="text/javascript" src="js/srs.utility.js"></script>
- <script type="text/javascript" src="js/winlin.utility.js"></script>
- <script type="text/javascript">
- var flvPlayer = null;
- var hlsPlayer = null;
- var stopPlayers = function () {
- if (flvPlayer) {
- flvPlayer.destroy();
- flvPlayer = null;
- }
- if (hlsPlayer) {
- hlsPlayer.destroy();
- hlsPlayer = null;
- }
- };
- var hide_for_error = function () {
- $('#main_flash_alert').show();
- $('#main_info').hide();
- $('#main_tips').hide();
- $('#video_player').hide();
- //$('#btn_play').hide();
- stopPlayers();
- };
- var show_for_ok = function () {
- $('#main_flash_alert').hide();
- $('#main_info').show();
- $('#main_tips').show();
- $('#video_player').show();
- //$('#btn_play').show();
- };
- var apply_url_change = function() {
- var r = parse_rtmp_url($("#txt_url").val());
- var url = window.location.protocol + "//" + query.host + query.pathname + "?autostart=true"
- + "&app=" + r.app + "&stream=" + r.stream + "&server=" + r.server + "&port=" + r.port;
- url += (query.shp_identify) ? "&shp_identify=" + query.shp_identify : '';
- url += (r.vhost === "__defaultVhost__") ? "&vhost=" + r.server : "&vhost=" + r.vhost;
- url += (r.schema !== "rtmp") ? "&schema=" + r.schema : '';
- url += (query.buffer) ? "&buffer=" + query.buffer : '';
- url += (query.api_port) ? "&api_port=" + query.api_port : '';
- var queries = user_extra_params(query);
- queries = user_extra_params(r, queries);
- if (queries && queries.length) {
- url += '&' + queries.join('&');
- }
- $("#player_url").text($("#txt_url").val()).attr("href", url);
- $("#link_url").attr("href", url);
- // For RTMP, not support.
- if (r.schema === 'rtmp') {
- hide_for_error();
- return;
- }
- return r;
- };
- var start_play = function (r) {
- stopPlayers();
- if (!r) return;
- // Start play HTTP-FLV.
- if (r.stream.indexOf('.flv') > 0) {
- if (!flvjs.isSupported()) {
- hide_for_error();
- return;
- }
- show_for_ok();
- flvPlayer = flvjs.createPlayer({type: 'flv', url: r.url});
- flvPlayer.attachMediaElement(document.getElementById('video_player'));
- flvPlayer.load();
- flvPlayer.play();
- return;
- }
- // Start play HLS.
- if (r.stream.indexOf('.m3u8') > 0) {
- if (!Hls.isSupported()) {
- hide_for_error();
- return;
- }
- show_for_ok();
- hlsPlayer = new Hls();
- hlsPlayer.loadSource(r.url);
- hlsPlayer.attachMedia(document.getElementById('video_player'));
- return;
- }
- console.error('不支持的URL', r.url, r);
- $('#video_player').hide();
- };
- $("#txt_url").change(function(){
- apply_url_change();
- });
- $("#btn_play").click(function(){
- $('#video_player').prop('muted', false);
- var r = apply_url_change();
- start_play(r);
- });
- /****
- * The parameters for this page:
- * schema, the protocol schema, rtmp or http.
- * server, the ip of the url.
- * port, the rtmp port of url.
- * vhost, the vhost of url, can equals to server.
- * app, the app of url.
- * stream, the stream of url, can endwith .flv or .mp4 or nothing for RTMP.
- * autostart, whether auto play the stream.
- * buffer, the buffer time in seconds.
- * extra params:
- * shp_identify, hls+ param.
- * for example:
- * http://localhost:8088/players/srs_player.html?vhost=ossrs.net&app=live&stream=livestream&server=ossrs.net&port=1935&autostart=true&schema=rtmp
- * http://localhost:8088/players/srs_player.html?vhost=ossrs.net&app=live&stream=livestream.flv&server=ossrs.net&port=8080&autostart=true&schema=http
- */
- var query = parse_query_string();
- // get the vhost and port to set the default url.
- // url set to: http://localhost:8080/live/livestream.flv
- srs_init_flv("#txt_url");
- if (query.autostart === "true") {
- $('#video_player').prop('muted', true);
- console.warn('For autostart, we should mute it, see https://www.jianshu.com/p/c3c6944eed5a ' +
- 'or https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#audiovideo_elements');
- var r = apply_url_change();
- start_play(r);
- } else {
- $('#video_player').hide();
- }
- </script>
- </html>
|