srs_player.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. #my_modal_footer {
  12. margin-top: -20px;
  13. padding-top: 3px;
  14. }
  15. .div_play_time {
  16. margin-top: 10px;
  17. }
  18. #pb_buffer_bg {
  19. margin-top: -4px;
  20. margin-bottom: 10px;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div class="navbar navbar-fixed-top">
  26. <div class="navbar-inner">
  27. <div class="container">
  28. <a id="srs_index" class="brand" href="#">SRS</a>
  29. <div class="nav-collapse collapse">
  30. <ul class="nav">
  31. <li class="active"><a id="nav_srs_player" href="srs_player.html">SRS播放器</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_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
  36. <li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
  37. <li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>
  38. </ul>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="container">
  44. <div class="alert alert-info fade in">
  45. <button type="button" class="close" data-dismiss="alert">×</button>
  46. <strong><span>Usage:</span></strong> <span>输入RTMP/HTTP地址后点击“播放视频”即可播放视频</span>
  47. </div>
  48. <div class="form-inline">
  49. URL:
  50. <input type="text" id="txt_url" class="input-xxlarge" value="">
  51. <button class="btn btn-primary" id="btn_play">播放视频</button>
  52. <button class="btn" id="btn_generate_link">生成链接</button>
  53. </div>
  54. <div id="link_modal" class="modal hide fade">
  55. <div class="modal-header">
  56. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  57. <h3><a href="https://github.com/ossrs/srs">SRS Link Generator</a></h3>
  58. </div>
  59. <div class="modal-body">
  60. <div class="form-horizontal">
  61. <div class="control-group">
  62. <label class="control-label" for="link_server">服务器地址</label>
  63. <div class="controls">
  64. <span id="link_server" class="span4 uneditable-input"></span>
  65. </div>
  66. </div>
  67. <div class="control-group">
  68. <label class="control-label" for="link_port">服务器端口</label>
  69. <div class="controls">
  70. <span id="link_port" class="span2 uneditable-input"></span>
  71. </div>
  72. </div>
  73. <div class="control-group">
  74. <label class="control-label" for="link_vhost">RTMP Vhost</label>
  75. <div class="controls">
  76. <span id="link_vhost" class="span4 uneditable-input"></span>
  77. </div>
  78. </div>
  79. <div class="control-group">
  80. <label class="control-label" for="link_app">RTMP App</label>
  81. <div class="controls">
  82. <span id="link_app" class="span4 uneditable-input"></span>
  83. </div>
  84. </div>
  85. <div class="control-group">
  86. <label class="control-label" for="link_stream">RTMP Stream</label>
  87. <div class="controls">
  88. <span id="link_stream" class="span4 uneditable-input"></span>
  89. </div>
  90. </div>
  91. <div class="control-group">
  92. <label class="control-label" for="link_rtmp">RTMP地址</label>
  93. <div class="controls">
  94. <span id="link_rtmp" class="span4 uneditable-input"></span>
  95. </div>
  96. </div>
  97. <div class="control-group">
  98. <label class="control-label" for="link_url">播放链接地址</label>
  99. <div class="controls">
  100. <div style="margin-top:5px;"><a href="#" id="link_url" target="_blank">请右键拷贝此链接地址.</a></div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="modal-footer"></div>
  106. </div>
  107. <div class="container">
  108. <hr/>
  109. <span>
  110. 注意:必须按照<a href="https://github.com/ossrs/srs/wiki/SampleDemo">SRS DEMO</a>
  111. 启动和设置服务器,下面所有的链接才能观看。
  112. </span>
  113. <div class="accordion" id="main_accordion">
  114. <div class="accordion-group">
  115. <div class="accordion-heading">
  116. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse1">
  117. <strong>[1] SRS示例播放流: 原始流</strong>
  118. </span>
  119. </div>
  120. <div id="collapse1" class="accordion-body collapse">
  121. <div class="accordion-inner">
  122. <a href="#" id="srs_publish">rtmp://demo.srs.com/live/livestream</a> <br/>
  123. <span>用户推送过来的唯一一路流,经过服务器的多种变换和再转发。</span>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="accordion-group">
  128. <div class="accordion-heading">
  129. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse10">
  130. <strong>[2] SRS示例播放流: 原始流HLS</strong>
  131. </span>
  132. </div>
  133. <div id="collapse10" class="accordion-body collapse">
  134. <div class="accordion-inner">
  135. <a href="#" id="srs_publish_hls" target="_blank">http://demo.srs.com/live/livestream.m3u8</a> <br/>
  136. <span>对用户的流进行HLS切片(若编码为非H264/AAC,HLS流会自动禁用)。</span>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="accordion-group">
  141. <div class="accordion-heading">
  142. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse2">
  143. <strong>[3] SRS示例播放流: 转码配置LD流</strong>
  144. </span>
  145. </div>
  146. <div id="collapse2" class="accordion-body collapse">
  147. <div class="accordion-inner">
  148. <a href="#" id="srs_publish_ld">rtmp://demo.srs.com/live/livestream_ld</a> <br/>
  149. <span>对原始流加了<a href="http://ffmpeg.org/ffmpeg-filters.html#overlay">FFMPEG图片水印</a></span>
  150. </div>
  151. </div>
  152. </div>
  153. <div class="accordion-group">
  154. <div class="accordion-heading">
  155. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse11">
  156. <strong>[4] SRS示例播放流: 转码配置LD流HLS</strong>
  157. </span>
  158. </div>
  159. <div id="collapse11" class="accordion-body collapse">
  160. <div class="accordion-inner">
  161. <a href="#" id="srs_publish_ld_hls" target="_blank">http://demo.srs.com/live/livestream_ld.m3u8</a> <br/>
  162. <span>对转码配置LD流进行HLS切片。</span>
  163. </div>
  164. </div>
  165. </div>
  166. <div class="accordion-group">
  167. <div class="accordion-heading">
  168. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse3">
  169. <strong>[5] SRS示例播放流: 转码配置SD流</strong>
  170. </span>
  171. </div>
  172. <div id="collapse3" class="accordion-body collapse">
  173. <div class="accordion-inner">
  174. <a href="#" id="srs_publish_sd">rtmp://demo.srs.com/live/livestream_sd</a> <br/>
  175. <span>对原始流应用了<a href="http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction">FFMPEG翻转滤镜</a></span>
  176. </div>
  177. </div>
  178. </div>
  179. <div class="accordion-group">
  180. <div class="accordion-heading">
  181. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse12">
  182. <strong>[6] SRS示例播放流: 转码配置SD流HLS</strong>
  183. </span>
  184. </div>
  185. <div id="collapse12" class="accordion-body collapse">
  186. <div class="accordion-inner">
  187. <a href="#" id="srs_publish_sd_hls" target="_blank">http://demo.srs.com/live/livestream_sd.m3u8</a> <br/>
  188. <span>对转码配置SD流进行HLS切片。</span>
  189. </div>
  190. </div>
  191. </div>
  192. <div class="accordion-group">
  193. <div class="accordion-heading">
  194. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse4">
  195. <strong>[7] SRS示例播放流: 转发原始流</strong>
  196. </span>
  197. </div>
  198. <div id="collapse4" class="accordion-body collapse">
  199. <div class="accordion-inner">
  200. <a href="#" id="srs_publish_fw">rtmp://demo.srs.com:19350/live/livestream</a> <br/>
  201. <span>将用户推送的流转发到另外的vhost或服务器,做热备用。</span>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="accordion-group">
  206. <div class="accordion-heading">
  207. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse13">
  208. <strong>[8] SRS示例播放流: 转发原始流HLS</strong>
  209. </span>
  210. </div>
  211. <div id="collapse13" class="accordion-body collapse">
  212. <div class="accordion-inner">
  213. <a href="#" id="srs_publish_fw_hls" target="_blank">http://demo.srs.com/forward/live/livestream.m3u8</a> <br/>
  214. <span>对转发原始流进行HLS切片(若编码为非H264/AAC,HLS流会自动禁用)。</span>
  215. </div>
  216. </div>
  217. </div>
  218. <div class="accordion-group">
  219. <div class="accordion-heading">
  220. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse5">
  221. <strong>[9] SRS示例播放流: 转发转码配置LD流</strong>
  222. </span>
  223. </div>
  224. <div id="collapse5" class="accordion-body collapse">
  225. <div class="accordion-inner">
  226. <a href="#" id="srs_publish_fw_ld">rtmp://demo.srs.com:19350/live/livestream_ld</a> <br/>
  227. <span>FFMPEG加水印后的流也会自动转发。</span>
  228. </div>
  229. </div>
  230. </div>
  231. <div class="accordion-group">
  232. <div class="accordion-heading">
  233. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse14">
  234. <strong>[10] SRS示例播放流: 转发转码配置LD流HLS</strong>
  235. </span>
  236. </div>
  237. <div id="collapse14" class="accordion-body collapse">
  238. <div class="accordion-inner">
  239. <a href="#" id="srs_publish_fw_ld_hls" target="_blank">http://demo.srs.com/forward/live/livestream_ld.m3u8</a> <br/>
  240. <span>对转发转码配置LD流进行HLS切片,所有转发的流会自动支持HLS。</span>
  241. </div>
  242. </div>
  243. </div>
  244. <div class="accordion-group">
  245. <div class="accordion-heading">
  246. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse6">
  247. <strong>[11] SRS示例播放流: 转发转码配置SD流</strong>
  248. </span>
  249. </div>
  250. <div id="collapse6" class="accordion-body collapse">
  251. <div class="accordion-inner">
  252. <a href="#" id="srs_publish_fw_sd">rtmp://demo.srs.com:19350/live/livestream_sd</a> <br/>
  253. <span>FFMPEG翻转后的流也会自动转发。</span>
  254. </div>
  255. </div>
  256. </div>
  257. <div class="accordion-group">
  258. <div class="accordion-heading">
  259. <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse15">
  260. <strong>[12] SRS示例播放流: 转发转码配置SD流HLS</strong>
  261. </span>
  262. </div>
  263. <div id="collapse15" class="accordion-body collapse">
  264. <div class="accordion-inner">
  265. <a href="#" id="srs_publish_fw_sd_hls" target="_blank">http://demo.srs.com/forward/live/livestream_sd.m3u8</a> <br/>
  266. <span>对转发转码配置SD流进行HLS切片,所有转发的流会自动支持HLS。</span>
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. <div id="main_modal" class="modal hide fade">
  273. <div class="modal-header">
  274. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  275. <h3><a href="https://github.com/ossrs/srs">SrsPlayer</a></h3>
  276. </div>
  277. <div class="modal-body">
  278. <div id="player"></div>
  279. <div class="progress progress-striped active" id="pb_buffer_bg">
  280. <div class="bar" style="width: 0%;" id="pb_buffer"></div>
  281. </div>
  282. </div>
  283. <div class="modal-footer" id="my_modal_footer">
  284. <div>
  285. <div class="btn-group dropup">
  286. <button class="btn dropdown-toggle" data-toggle="dropdown">
  287. 设置全屏比例大小<span class="caret"></span>
  288. </button>
  289. <ul class="dropdown-menu">
  290. <li><a id="btn_fs_size_screen_100" href="#">屏幕大小(100%)</a></li>
  291. <li><a id="btn_fs_size_screen_75" href="#">屏幕大小(75%)</a></li>
  292. <li><a id="btn_fs_size_screen_50" href="#">屏幕大小(50%)</a></li>
  293. <li><a id="btn_fs_size_video_100" href="#">视频大小(100%)</a></li>
  294. <li><a id="btn_fs_size_video_75" href="#">视频大小(75%)</a></li>
  295. <li><a id="btn_fs_size_video_50" href="#">视频大小(50%)</a></li>
  296. </ul>
  297. </div>
  298. <div class="btn-group dropup">
  299. <button class="btn dropdown-toggle" data-toggle="dropdown">设置显示比例<span class="caret"></span></button>
  300. <ul class="dropdown-menu">
  301. <li><a id="btn_dar_original" href="#">视频原始比例</a></li>
  302. <li><a id="btn_dar_21_9" href="#">宽屏影院(21:9)</a></li>
  303. <li><a id="btn_dar_16_9" href="#">宽屏电视(16:9)</a></li>
  304. <li><a id="btn_dar_4_3" href="#">窄屏(4:3)</a></li>
  305. <li><a id="btn_dar_fill" href="#">填充(容器比例)</a></li>
  306. </ul>
  307. </div>
  308. <div class="btn-group dropup">
  309. <button class="btn dropdown-toggle" data-toggle="dropdown">设置缓冲区大小<span class="caret"></span></button>
  310. <ul class="dropdown-menu">
  311. <li><a id="btn_bt_0_1" href="#">0.1秒(实时)</a></li>
  312. <li><a id="btn_bt_0_2" href="#">0.2秒(实时)</a></li>
  313. <li><a id="btn_bt_0_3" href="#">0.3秒(实时)</a></li>
  314. <li><a id="btn_bt_0_5" href="#">0.5秒(实时)</a></li>
  315. <li><a id="btn_bt_0_8" href="#">0.8秒(会议)</a></li>
  316. <li><a id="btn_bt_1_0" href="#">1秒(低延迟)</a></li>
  317. <li><a id="btn_bt_2_0" href="#">2秒(较低延时)</a></li>
  318. <li><a id="btn_bt_3_0" href="#">3秒(流畅播放)</a></li>
  319. <li><a id="btn_bt_4_0" href="#">4秒(流畅播放)</a></li>
  320. <li><a id="btn_bt_5_0" href="#">5秒(网速较低)</a></li>
  321. <li><a id="btn_bt_6_0" href="#">6秒(网速较低)</a></li>
  322. <li><a id="btn_bt_8_0" href="#">8秒(网速较低)</a></li>
  323. <li><a id="btn_bt_10_0" href="#">10秒(无所谓延迟)</a></li>
  324. <li><a id="btn_bt_15_0" href="#">15秒(无所谓延迟)</a></li>
  325. <li><a id="btn_bt_20_0" href="#">20秒(无所谓延迟)</a></li>
  326. <li><a id="btn_bt_30_0" href="#">30秒(流畅第一)</a></li>
  327. </ul>
  328. </div>
  329. <div class="btn-group dropup">
  330. <button class="btn dropdown-toggle" data-toggle="dropdown">最大缓冲区<span class="caret"></span></button>
  331. <ul class="dropdown-menu">
  332. <li><a id="btn_mbt_0_6" href="#">0.6秒(实时)</a></li>
  333. <li><a id="btn_mbt_0_9" href="#">0.9秒(实时)</a></li>
  334. <li><a id="btn_mbt_1_2" href="#">1.2秒(实时)</a></li>
  335. <li><a id="btn_mbt_1_5" href="#">1.5秒(实时)</a></li>
  336. <li><a id="btn_mbt_2_4" href="#">2.4秒(会议)</a></li>
  337. <li><a id="btn_mbt_3_0" href="#">3秒(低延迟)</a></li>
  338. <li><a id="btn_mbt_6_0" href="#">6秒(较低延时)</a></li>
  339. <li><a id="btn_mbt_9_0" href="#">9秒(流畅播放)</a></li>
  340. <li><a id="btn_mbt_12_0" href="#">12秒(流畅播放)</a></li>
  341. <li><a id="btn_mbt_15_0" href="#">15秒(网速较低)</a></li>
  342. <li><a id="btn_mbt_18_0" href="#">18秒(网速较低)</a></li>
  343. <li><a id="btn_mbt_24_0" href="#">24秒(网速较低)</a></li>
  344. <li><a id="btn_mbt_30_0" href="#">30秒(无所谓延迟)</a></li>
  345. <li><a id="btn_mbt_45_0" href="#">45秒(无所谓延迟)</a></li>
  346. <li><a id="btn_mbt_60_0" href="#">60秒(无所谓延迟)</a></li>
  347. <li><a id="btn_mbt_90_0" href="#">90秒(流畅第一)</a></li>
  348. </ul>
  349. </div>
  350. <div class="btn-group dropup">
  351. <a id="btn_fullscreen" class="btn">进入全屏</a>
  352. </div>
  353. <div class="btn-group dropup">
  354. <button id="btn_pause" class="btn">暂停播放</button>
  355. <button id="btn_resume" class="btn hide">继续播放</button>
  356. </div>
  357. <div class="btn-group dropup">
  358. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">关闭播放器</button>
  359. </div>
  360. </div>
  361. <div class="hide" id="fullscreen_tips">
  362. 请<font color="red">点击视频</font>进入全屏模式~<br/>
  363. 由于安全原因,Flash全屏无法使用JS触发
  364. </div>
  365. <div>
  366. <div class="input-prepend div_play_time" title="视频的播放流畅度">
  367. <span class="add-on">@F</span>
  368. <input class="span2" style="width:57px" id="txt_fluency" type="text" placeholder="100%">
  369. </div>
  370. <div class="input-prepend div_play_time" title="视频总共卡顿次数">
  371. <span class="add-on">@E</span>
  372. <input class="span2" style="width:85px" id="txt_empty_count" type="text" placeholder="0">
  373. </div>
  374. <div class="input-prepend div_play_time" title="视频当前的帧率FPS">
  375. <span class="add-on">@F</span>
  376. <input class="span2" style="width:85px" id="txt_fps" type="text" placeholder="fps">
  377. </div>
  378. <div class="input-prepend div_play_time" title="视频当前的码率(视频+音频),单位:Kbps">
  379. <span class="add-on">@B</span>
  380. <input class="span2" style="width:85px" id="txt_bitrate" type="text" placeholder="kbps">
  381. </div>
  382. <div class="input-prepend div_play_time" title="播放时长,格式:天 时:分:秒">
  383. <span class="add-on">@T</span>
  384. <input class="span2" style="width:85px" id="txt_time" type="text" placeholder="天 时:分:秒">
  385. </div>
  386. </div>
  387. <div style="margin-top:-12px;">
  388. URL: <a href="#" id="player_url"></a>
  389. <div class="input-prepend div_play_time" title="当前时间:年-月-日 时:分:秒">
  390. <span class="add-on">@N</span>
  391. <input class="span2" style="width:135px" id="player_clock" type="text" placeholder="年-月-日 时:分:秒">
  392. </div>
  393. </div>
  394. </div>
  395. </div>
  396. <footer>
  397. <p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2013</a></p>
  398. </footer>
  399. </div>
  400. </body>
  401. <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
  402. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  403. <script type="text/javascript" src="js/swfobject.js"></script>
  404. <script type="text/javascript" src="js/json2.js"></script>
  405. <script type="text/javascript" src="js/srs.page.js"></script>
  406. <script type="text/javascript" src="js/srs.log.js"></script>
  407. <script type="text/javascript" src="js/srs.player.js"></script>
  408. <script type="text/javascript" src="js/srs.publisher.js"></script>
  409. <script type="text/javascript" src="js/srs.utility.js"></script>
  410. <script type="text/javascript" src="js/winlin.utility.js"></script>
  411. <script type="text/javascript">
  412. var srs_player = null;
  413. var url = null;
  414. var __active_dar = null;
  415. function select_dar(dar_id, num, den) {
  416. srs_player.set_dar(num, den);
  417. if (__active_dar) {
  418. __active_dar.removeClass("active");
  419. }
  420. __active_dar = $(dar_id).parent();
  421. __active_dar.addClass("active");
  422. }
  423. var __active_size = null;
  424. function select_fs_size(size_id, refer, percent) {
  425. srs_player.set_fs(refer, percent);
  426. if (__active_size) {
  427. __active_size.removeClass("active");
  428. }
  429. __active_size = $(size_id).parent();
  430. __active_size.addClass("active");
  431. }
  432. var __active_bt = null;
  433. function select_buffer_time(bt_id, buffer_time) {
  434. srs_player.set_bt(buffer_time);
  435. if (__active_bt) {
  436. __active_bt.removeClass("active");
  437. }
  438. __active_bt = $(bt_id).parent();
  439. __active_bt.addClass("active");
  440. }
  441. $(function(){
  442. var query = parse_query_string();
  443. // get the vhost and port to set the default url.
  444. // for example: http://192.168.1.213/players/jwplayer6.html?port=1935&vhost=demo
  445. // url set to: rtmp://demo:1935/live/livestream
  446. srs_init_rtmp("#txt_url", "#main_modal");
  447. // consts for buffer and max buffer.
  448. var bts = [0.1, 0.2, 0.3, 0.5, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 30];
  449. var mbts = [0.6, 0.9, 1.2, 1.5, 2.4, 3, 6, 9, 12, 15, 18, 24, 30, 45, 60, 90];
  450. // the play startup time.
  451. var pst = new Date();
  452. $("#main_modal").on("show", function(){
  453. if (srs_player) {
  454. return;
  455. }
  456. $("#div_container").remove();
  457. var div_container = $("<div/>");
  458. $(div_container).attr("id", "div_container");
  459. $("#player").append(div_container);
  460. var player = $("<div/>");
  461. $(player).attr("id", "player_id");
  462. $(div_container).append(player);
  463. srs_player = new SrsPlayer("player_id", srs_get_player_width(), srs_get_player_height());
  464. srs_player.on_player_ready = function() {
  465. var buffer_time = 0.5;
  466. if (url.indexOf('.m3u8') > 0) {
  467. buffer_time = 2;
  468. }
  469. if (query.buffer) {
  470. for (var i = 0; i < bts.length - 1; i++) {
  471. var cur = bts[i];
  472. var next = bts[i+1];
  473. if (Number(query.buffer) >= cur && Number(query.buffer) < next) {
  474. buffer_time = cur;
  475. break;
  476. }
  477. }
  478. }
  479. select_buffer(buffer_time);
  480. this.play(url);
  481. };
  482. srs_player.on_player_metadata = function(metadata) {
  483. $("#btn_dar_original").text("视频原始比例" + "(" + metadata.width + ":" + metadata.height + ")");
  484. select_dar("#btn_dar_original", 0, 0);
  485. select_fs_size("#btn_fs_size_screen_100", "screen", 100);
  486. };
  487. srs_player.on_player_timer = function(time, buffer_length, kbps, fps, rtime) {
  488. var buffer = buffer_length / this.buffer_time * 100;
  489. $("#pb_buffer").width(Number(buffer).toFixed(1) + "%");
  490. $("#pb_buffer_bg").attr("title",
  491. "缓冲区长度:" + Number(buffer_length).toFixed(1) + "秒("
  492. + Number(buffer).toFixed(1) + "%)");
  493. $("#txt_bitrate").val(kbps.toFixed(1) + "kbps");
  494. $("#txt_fps").val(fps.toFixed(1) + "fps");
  495. $("#txt_empty_count").val(srs_player.empty_count() + "次卡顿");
  496. $("#txt_fluency").val(srs_player.fluency().toFixed(2) + "%");
  497. var time_str = "";
  498. // day
  499. time_str = padding(parseInt(time / 24 / 3600), 2, '0') + " ";
  500. // hour
  501. time = time % (24 * 3600);
  502. time_str += padding(parseInt(time / 3600), 2, '0') + ":";
  503. // minute
  504. time = time % (3600);
  505. time_str += padding(parseInt(time / 60), 2, '0') + ":";
  506. // seconds
  507. time = time % (60);
  508. time_str += padding(parseInt(time), 2, '0');
  509. // show
  510. $("#txt_time").val(time_str);
  511. var clock = new Date().getTime() / 1000;
  512. $("#player_clock").val(absolute_seconds_to_YYYYmmdd(clock) + " " + absolute_seconds_to_HHMMSS(clock));
  513. };
  514. srs_player.start();
  515. });
  516. $("#main_modal").on("hide", function(){
  517. if (srs_player) {
  518. srs_player.stop();
  519. srs_player = null;
  520. }
  521. });
  522. var apply_url_change = function() {
  523. var rtmp = parse_rtmp_url($("#txt_url").val());
  524. var url = "http://" + query.host + query.pathname + "?"
  525. + "vhost=" + rtmp.vhost + "&app=" + rtmp.app + "&stream=" + rtmp.stream
  526. + "&server=" + rtmp.server + "&port=" + rtmp.port
  527. + "&autostart=true";
  528. $("#player_url").text($("#txt_url").val()).attr("href", url);
  529. $("#link_server").text(rtmp.server);
  530. $("#link_port").text(rtmp.port);
  531. $("#link_vhost").text(rtmp.vhost);
  532. $("#link_app").text(rtmp.app);
  533. $("#link_stream").text(rtmp.stream);
  534. $("#link_rtmp").text($("#txt_url").val());
  535. $("#link_url").attr("href", url);
  536. };
  537. $("#txt_url").change(function(){
  538. apply_url_change();
  539. });
  540. $("#btn_generate_link").click(function(){
  541. $("#link_modal").modal({show:true, keyboard:true});
  542. });
  543. $("#btn_play").click(function(){
  544. url = $("#txt_url").val();
  545. $("#main_modal").modal({show:true, keyboard:true});
  546. });
  547. $("#btn_fullscreen").click(function(){
  548. $("#fullscreen_tips").toggle();
  549. });
  550. $("#btn_pause").click(function() {
  551. $("#btn_resume").toggle();
  552. $("#btn_pause").toggle();
  553. srs_player.pause();
  554. });
  555. $("#btn_resume").click(function(){
  556. $("#btn_resume").toggle();
  557. $("#btn_pause").toggle();
  558. srs_player.resume();
  559. });
  560. if (true) {
  561. $("#srs_publish").click(function () {
  562. url = $("#srs_publish").text();
  563. $("#main_modal").modal({show: true, keyboard: false});
  564. });
  565. $("#srs_publish_ld").click(function () {
  566. url = $("#srs_publish_ld").text();
  567. $("#main_modal").modal({show: true, keyboard: false});
  568. });
  569. $("#srs_publish_sd").click(function () {
  570. url = $("#srs_publish_sd").text();
  571. $("#main_modal").modal({show: true, keyboard: false});
  572. });
  573. $("#srs_publish_fw").click(function () {
  574. url = $("#srs_publish_fw").text();
  575. $("#main_modal").modal({show: true, keyboard: false});
  576. });
  577. $("#srs_publish_fw_ld").click(function () {
  578. url = $("#srs_publish_fw_ld").text();
  579. $("#main_modal").modal({show: true, keyboard: false});
  580. });
  581. $("#srs_publish_fw_sd").click(function () {
  582. url = $("#srs_publish_fw_sd").text();
  583. $("#main_modal").modal({show: true, keyboard: false});
  584. });
  585. }
  586. var jwplayer_url = "http://" + query.host + query.dir + "/jwplayer6.html?vhost=demo.srs.com&app=live&hls_autostart=true";
  587. if (true) {
  588. $("#srs_publish_hls").attr("href", jwplayer_url + "&stream=livestream");
  589. $("#srs_publish_ld_hls").attr("href", jwplayer_url + "&stream=livestream_ld");
  590. $("#srs_publish_sd_hls").attr("href", jwplayer_url + "&stream=livestream_sd");
  591. var jwplayer_url = "http://" + query.host + query.dir + "/jwplayer6.html?vhost=demo.srs.com&app=forward/live&hls_autostart=true";
  592. $("#srs_publish_fw_hls").attr("href", jwplayer_url + "&stream=livestream");
  593. $("#srs_publish_fw_ld_hls").attr("href", jwplayer_url + "&stream=livestream_ld");
  594. $("#srs_publish_fw_sd_hls").attr("href", jwplayer_url + "&stream=livestream_sd");
  595. }
  596. if (true) {
  597. $("#btn_dar_original").click(function(){
  598. select_dar("#btn_dar_original", 0, 0);
  599. });
  600. $("#btn_dar_21_9").click(function(){
  601. select_dar("#btn_dar_21_9", 21, 9);
  602. });
  603. $("#btn_dar_16_9").click(function(){
  604. select_dar("#btn_dar_16_9", 16, 9);
  605. });
  606. $("#btn_dar_4_3").click(function(){
  607. select_dar("#btn_dar_4_3", 4, 3);
  608. });
  609. $("#btn_dar_fill").click(function(){
  610. select_dar("#btn_dar_fill", -1, -1);
  611. });
  612. }
  613. if (true) {
  614. $("#btn_fs_size_video_100").click(function(){
  615. select_fs_size("#btn_fs_size_video_100", "video", 100);
  616. });
  617. $("#btn_fs_size_video_75").click(function(){
  618. select_fs_size("#btn_fs_size_video_75", "video", 75);
  619. });
  620. $("#btn_fs_size_video_50").click(function(){
  621. select_fs_size("#btn_fs_size_video_50", "video", 50);
  622. });
  623. $("#btn_fs_size_screen_100").click(function(){
  624. select_fs_size("#btn_fs_size_screen_100", "screen", 100);
  625. });
  626. $("#btn_fs_size_screen_75").click(function(){
  627. select_fs_size("#btn_fs_size_screen_75", "screen", 75);
  628. });
  629. $("#btn_fs_size_screen_50").click(function(){
  630. select_fs_size("#btn_fs_size_screen_50", "screen", 50);
  631. });
  632. }
  633. if (true) {
  634. $("#btn_bt_0_1").click(function(){
  635. select_buffer_time("#btn_bt_0_1", 0.1);
  636. });
  637. $("#btn_bt_0_2").click(function(){
  638. select_buffer_time("#btn_bt_0_2", 0.2);
  639. });
  640. $("#btn_bt_0_3").click(function(){
  641. select_buffer_time("#btn_bt_0_3", 0.3);
  642. });
  643. $("#btn_bt_0_5").click(function(){
  644. select_buffer_time("#btn_bt_0_5", 0.5);
  645. });
  646. $("#btn_bt_0_8").click(function(){
  647. select_buffer_time("#btn_bt_0_8", 0.8);
  648. });
  649. $("#btn_bt_1").click(function(){
  650. select_buffer_time("#btn_bt_1", 1);
  651. });
  652. $("#btn_bt_2").click(function(){
  653. select_buffer_time("#btn_bt_2", 2);
  654. });
  655. $("#btn_bt_3").click(function(){
  656. select_buffer_time("#btn_bt_3", 3);
  657. });
  658. $("#btn_bt_5").click(function(){
  659. select_buffer_time("#btn_bt_5", 5);
  660. });
  661. $("#btn_bt_10").click(function(){
  662. select_buffer_time("#btn_bt_10", 10);
  663. });
  664. $("#btn_bt_30").click(function(){
  665. select_buffer_time("#btn_bt_30", 30);
  666. });
  667. }
  668. var query = parse_query_string();
  669. if (query.autostart == "true") {
  670. url = $("#txt_url").val();
  671. $("#main_modal").modal({show:true, keyboard:false});
  672. }
  673. apply_url_change();
  674. });
  675. </script>
  676. </html>