remote_flv_view.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>Remote View</title>
  8. <link rel="stylesheet" href="./css/common.css?v=202305271602" />
  9. <style>
  10. #remote_view {
  11. width: 100%;
  12. height: 100%;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <canvas id="remote_view"></canvas>
  18. <script src="./lib/jquery/jquery.min.js"></script>
  19. <script src="./lib/node_player_0.12.6/NodePlayer.min.js"></script>
  20. <!-- <script src="./lib/debug/NodePlayer.min.js"></script> -->
  21. <script src="./js/common.js?v=202311141652"></script>
  22. <script src="./js/rtmp_video_capturer.js?v=202306031755"></script>
  23. <script src="./lib/device_live/player.js"></script>
  24. <script>
  25. async function start() {
  26. await LivePlayer.init();
  27. var url = getQueryString("url");
  28. console.log("%c 🔥🔥🔥🔥 remote_view start", "color:#4fff4B", url);
  29. var player = new LivePlayer("remote_view", url);
  30. function onResize() {
  31. let width = window.innerWidth;
  32. let height = window.innerHeight;
  33. player.setViewSize(width, height);
  34. }
  35. addResizeCallback(function () {
  36. onResize();
  37. });
  38. player.onBuffer = function (state) {
  39. console.log("%c 🔥🔥🔥🔥 onBuffer", "color:#ed9ec7",state);
  40. };
  41. player.onPlay = function () {
  42. console.log("%c 🔥🔥🔥🔥 onPlay", "color:#ed9ec7");
  43. };
  44. player.onBeforeReconnect = () => {
  45. console.log("%c 🔥🔥🔥🔥 onBeforeReconnect", "color:#ed9ec7");
  46. };
  47. player.onInfo = function (info) {
  48. onResize();
  49. };
  50. player.onTimeout = function () {
  51. console.log(
  52. "%c Line:57 🥔 onTimeout",
  53. "color:#2eafb0",
  54. "timeout 10s"
  55. );
  56. };
  57. player.onAudioInfo = function (info) {};
  58. player.play(true);
  59. function play() {
  60. player.start(url);
  61. }
  62. function stop() {
  63. player.stop();
  64. }
  65. // 0-100
  66. function setVolume(volume) {
  67. // 0.0-1.0
  68. player.setVolume(volume / 100);
  69. }
  70. function setAudioMute(isMute) {
  71. player.enableAudio(!isMute);
  72. }
  73. function setVideoMute(isMute) {
  74. player.enableVideo(!isMute);
  75. }
  76. function regMsgEventBus() {
  77. var fnMap = {
  78. play: play,
  79. stop: stop,
  80. setVolume: setVolume,
  81. setAudioMute: setAudioMute,
  82. setVideoMute: setVideoMute,
  83. mountSubView: function () {},
  84. };
  85. window.addEventListener("message", function (e) {
  86. var msg = e.data;
  87. var method = msg.method;
  88. var fn = fnMap[method];
  89. if (!!fn) {
  90. var data = msg.data;
  91. fn(data);
  92. }
  93. });
  94. }
  95. regMsgEventBus();
  96. }
  97. start();
  98. </script>
  99. </body>
  100. </html>