Browse Source

'初始化'

hzh 2 years ago
commit
485c20419d
9 changed files with 1063 additions and 0 deletions
  1. 63 0
      flv/demo.css
  2. 8 0
      flv/flv.min.js
  3. 0 0
      flv/flv.min.js.map
  4. 45 0
      flv/hls.html
  5. 54 0
      flv/iframeflv.html
  6. 271 0
      flv/index.html
  7. 149 0
      flv/indexcontroller.html
  8. 327 0
      flv/indexcontroller.js
  9. 146 0
      flv/jquery.base64.js

+ 63 - 0
flv/demo.css

@@ -0,0 +1,63 @@
+body {
+  display: block;
+  width: 100%;
+  margin-left: auto;
+  margin-right: auto;
+}
+@media screen and (min-width: 1152px) {
+  .mainContainer {
+    display: block;
+    width: 400px;
+    text-align: left;
+  }
+}
+
+.video-container {
+  position: relative;
+  margin-top: 8px;
+}
+
+.video-container:before {
+  display: block;
+  content: "";
+  width: 100%;
+  padding-bottom: 56.25%;
+}
+
+.video-container > div {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+
+.video-container video {
+  width: 100%;
+  height: 100%;
+}
+
+.centeredVideo {
+  display: block;
+  width: 100%;
+  height: 100%;
+  margin-left: auto;
+  margin-right: auto;
+  margin-bottom: auto;
+}
+
+.allcontrols {
+  width: 960px;
+  margin-left: auto;
+  margin-right: auto;
+}
+
+.controls {
+  display: block;
+  width: 100%;
+  text-align: left;
+  margin-left: auto;
+  margin-right: auto;
+  margin-top: 8px;
+  margin-bottom: 10px;
+}

File diff suppressed because it is too large
+ 8 - 0
flv/flv.min.js


File diff suppressed because it is too large
+ 0 - 0
flv/flv.min.js.map


+ 45 - 0
flv/hls.html

@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+	<head>
+		<meta charset="UTF-8">
+		<title>播放m3u8格式</title>
+		<link href="https://unpkg.com/video.js/dist/video-js.css" rel="stylesheet">
+		<script src="https://unpkg.com/video.js/dist/video.js"></script>
+		<script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script>
+		<!-- videojs-contrib-hls 用于在电脑端播放 如果只需移动端播放可以不引入 -->
+	</head>
+	<body>
+		<style>
+			.video-js .vjs-tech {position: relative !important;}
+    	</style>
+		<div>
+			<video id="myVideo" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" data-setup='{}'
+			 style='width: 100%;height: auto'>
+				<source id="source" src="http://192.168.1.100:9996/rtp/06516E8D/hls.m3u8" type="application/x-mpegURL">
+				</source>
+			</video>
+		</div>
+	</body>
+
+	<script>
+		var myVideo = videojs('myVideo', {
+			bigPlayButton: true,
+			textTrackDisplay: false,
+			posterImage: false,
+			errorDisplay: false,
+		})
+		myVideo.play()
+		var changeVideo = function(vdoSrc) {
+			if (/\.m3u8$/.test(vdoSrc)) {
+				myVideo.src({
+					src: vdoSrc,
+					type: 'application/x-mpegURL'
+				})
+			} else {
+				myVideo.src(vdoSrc)
+			}
+			myVideo.load();
+			myVideo.play();
+		}
+	</script>
+

+ 54 - 0
flv/iframeflv.html

@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+  </head>
+  <body onload="play()">
+    <div>
+      <video
+        id="videoElement"
+        class="centeredVideo"
+        controls
+        width="960"
+        height="576"
+      >
+        Your browser is too old which doesn't support HTML5 video.
+      </video>
+    </div>
+  </body>
+  <script src="flv.min.js"></script>
+  <script>
+    function getQueryString(name) {
+      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+      var r = window.location.search.substr(1).match(reg);
+      if (r != null) {
+        return unescape(r[2]);
+      }
+      return null;
+    }
+
+    function play() {
+      var playurl = getQueryString("playurl");
+      console.log(playurl);
+      if (playurl != null && playurl != "") {
+        var flvPlayer;
+        var player = document.getElementById("videoElement");
+
+        if (flvjs.isSupported()) {
+          flvPlayer = flvjs.createPlayer({
+            isLive: true,
+            type: "flv",
+            url: playurl,
+          });
+
+          flvPlayer.attachMediaElement(player);
+          flvPlayer.load(); //加载
+          flvPlayer.play();
+        }
+      }
+    }
+  </script>
+</html>

+ 271 - 0
flv/index.html

@@ -0,0 +1,271 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+    <title>flv.js demo</title>
+    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
+    <script src="jquery.base64.js"></script>
+    <script type="text/javascript">
+      $(document).ready(function () {
+        let token =
+          "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb21wYW55SWQiOiI1MDc0NDY2NjU1NjUyNDU0NDAiLCJsb2dpbk5hbWUiOiJhZG1pbiIsImN1cnJlbnRUaW1lTWlsbGlzIjoiMTY4MTU2OTMzNTI3MiIsImV4cCI6MTY4MTU3NjUzNSwidXNlcklkIjoiNTEzNjA0MzE2MTQ1NzE3MjQ4In0.xSg5C0tqCQfDbKnHHLKMGPgWa9k3dnfb5QmpJSOG-tg";
+
+        function login() {
+          var domain = $("#domain").val();
+          var loginName = $("#loginName").val();
+          var pass = $("#pass").val();
+          //  var password = $.base64.encode(pass);
+          var password = pass;
+          $.post(
+            domain + "/system/login",
+            { loginName: loginName, password: password, type: 1 },
+            function (data, status) {
+              if (status == "success") {
+                if (data.errorCode == 0) {
+                  token = data.data;
+                } else {
+                  alert(data.desc);
+                }
+              }
+            }
+          );
+        }
+
+        function close() {
+          var domain = $("#domain").val();
+          var deviceId = $("#deviceId").val();
+          var channel = $("#channel").val();
+
+          var curDeviceId = $("#curDeviceId").html();
+          var curChannel = $("#curChannel").html();
+
+          $.ajax(domain + "/core/Jtt808Order/videoHisControl", {
+            type: "post",
+            dataType: "json",
+            contentType: "application/json",
+            data: JSON.stringify({
+              channel: curChannel == "" ? channel : curChannel,
+              playback: 2,
+              deviceId: curDeviceId == "" ? deviceId : curDeviceId,
+            }),
+            headers: { Authorization: token },
+            success: function (data, status) {
+              if (status == "success") {
+                if (data.errorCode == 0) {
+                  alert("关闭成功");
+                  $("#curDeviceId").html("");
+                  $("#curChannel").html("");
+                  document.getElementById("playurl").value = "";
+
+                  mainFrame = document.getElementById("mainFrame");
+                  mainFrame.src = "iframeflv.html";
+                  mainFrame.location.reload();
+                } else {
+                  alert(data.desc);
+                }
+              }
+            },
+          });
+        }
+
+        function order() {
+          var domain = $("#domain").val();
+          var deviceId = $("#deviceId").val();
+          var channel = $("#channel").val();
+          var start = $("#start").val();
+          var end = $("#end").val();
+
+          $.ajax(domain + "/core/Jtt808Order/videoHis", {
+            type: "post",
+            dataType: "json",
+            contentType: "application/json",
+            data: JSON.stringify({
+              channel: channel,
+              dataRate: 0,
+              dataType: 0,
+              deviceId: deviceId,
+              startTime: start,
+              endTime: end,
+              fastTimes: 0,
+              playback: 0,
+              storageType: 0,
+            }),
+            headers: { Authorization: token },
+            success: function (data, status) {
+              if (status == "success") {
+                if (data.errorCode == 0) {
+                  document.getElementById("playurl").value =
+                    domain +
+                    "/video/history/" +
+                    deviceId +
+                    "-" +
+                    channel +
+                    "/time1681547649168";
+
+                  $("#curDeviceId").html(deviceId);
+                  $("#curChannel").html(channel);
+                } else {
+                  alert(data.desc);
+                }
+              }
+            },
+          });
+        }
+
+        function play() {
+          var playurl = document.getElementById("playurl").value;
+          mainFrame = document.getElementById("mainFrame");
+          mainFrame.src = "iframeflv.html?playurl=" + playurl;
+          mainFrame.location.reload();
+        }
+
+        function all() {
+          var domain = $("#domain").val();
+          var deviceId = $("#deviceId").val();
+          var channel = $("#channel").val();
+          var start = $("#start").val();
+          var end = $("#end").val();
+          var curDeviceId = $("#curDeviceId").html();
+          var curChannel = $("#curChannel").html();
+
+          $.ajax(domain + "/core/Jtt808Order/videoHisControl", {
+            type: "post",
+            dataType: "json",
+            contentType: "application/json",
+            data: JSON.stringify({
+              channel: curChannel == "" ? channel : curChannel,
+              playback: 2,
+              deviceId: curDeviceId == "" ? deviceId : curDeviceId,
+            }),
+            headers: { Authorization: token },
+            success: function (data, status) {
+              if (status == "success") {
+                if (data.errorCode == 0) {
+                  $.ajax(domain + "/core/Jtt808Order/videoHis", {
+                    type: "post",
+                    dataType: "json",
+                    contentType: "application/json",
+                    data: JSON.stringify({
+                      channel: channel,
+                      dataRate: 1,
+                      dataType: 0,
+                      deviceId: deviceId,
+                      startTime: start,
+                      endTime: end,
+                      fastTimes: 0,
+                      playback: 0,
+                      storageType: 0,
+                    }),
+                    headers: { Authorization: token },
+                    success: function (data, status) {
+                      if (status == "success") {
+                        if (data.errorCode == 0) {
+                          document.getElementById("playurl").value =
+                            domain +
+                            "/video/history/" +
+                            deviceId +
+                            "-" +
+                            channel +
+                            "/time1681547649168";
+
+                          $("#curDeviceId").html(deviceId);
+                          $("#curChannel").html(channel);
+                          play();
+                        } else {
+                          alert(data.desc);
+                        }
+                      }
+                    },
+                  });
+                } else {
+                  alert(data.desc);
+                }
+              }
+            },
+          });
+        }
+
+        $("#login").click(function () {
+          login();
+        });
+
+        $("#close").click(function () {
+          close();
+        });
+
+        $("#order").click(function () {
+          order();
+        });
+
+        $("#play").click(function () {
+          play();
+        });
+
+        $("#all").click(function () {
+          all();
+        });
+      });
+    </script>
+    <link type="text/css" rel="stylesheet" href="demo.css" />
+  </head>
+
+  <body>
+    <div class="allcontrols">
+      <div class="controls">
+        域名:<input
+          id="domain"
+          type="text"
+          value="https://gdabczjk.grgbanking.com/"
+        />
+        账号: <input type="text" name="" id="loginName" value="admin" /> 账号:
+        <input
+          type="password"
+          name=""
+          id="pass"
+          value="FbhQnrFLJYnTIm/t493tsX8xMH9+Bn0k07m8Fqz/QD1ZDVRSG6aTyfcGDUtCsjB1qO5iWik1qAupd3FAA/PkY3jQ5i/w2rhNyD/Yszuq+iq3yQ/u17zGGWy42COoAWrlYfHBm+3VE5ATOCoREl4tjPOb5j5+FBoyrjJPCPRJ/wE="
+        />
+        <button id="login">登录获取token</button>
+      </div>
+      <div class="controls">
+        设备Id:<input id="deviceId" type="text" value="13812345012" />
+        通道号:<input id="channel" type="text" value="1" /> 开始时间:
+        <input id="start" type="text" value="2023-07-22 08:13:41" />
+        结束时间:<input id="end" type="text" value="2023-07-22 23:00:00" />
+      </div>
+
+      <div class="controls">
+        <input
+          style="width: 900px"
+          type="text"
+          id="playurl"
+          autofocus="autofocus"
+        />
+      </div>
+
+      <div class="controls">
+        <button id="close">关闭回放</button>
+        <button id="order">下发播放指令</button>
+        <button id="play">播放</button>
+
+        <button id="all">综合关闭-下发播放指令-播放</button>
+      </div>
+
+      <div class="controls">
+        当前播放的信息: 设备Id:<span id="curDeviceId"></span> 通道号:
+        <span id="curChannel"></span>
+      </div>
+
+      <iframe
+        id="mainFrame"
+        src="iframeflv.html"
+        width="960px"
+        height="500px"
+        scrolling="no"
+      >
+      </iframe>
+    </div>
+  </body>
+  <script>
+    function flv_start() {}
+  </script>
+</html>

+ 149 - 0
flv/indexcontroller.html

@@ -0,0 +1,149 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+    <title>flv.js demo</title>
+    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
+    <script src="jquery.base64.js"></script>
+    <script src="flv.min.js"></script>
+    <script type="text/javascript" src="indexcontroller.js"></script>
+    <link type="text/css" rel="stylesheet" href="demo.css" />
+  </head>
+
+  <body>
+    <div class="allcontrols">
+      <div class="controls">
+        域名:<input id="domain" type="text" value="https://80.5000v.com/" />
+        账号: <input type="text" name="" id="loginName" value="admin" /> 账号:
+        <input type="password" name="" id="pass" value="R0R0cUAxOTgxJSU=" />
+        <button id="login">登录获取token</button>
+      </div>
+
+      <div class="controls">
+        设备Id:<input id="deviceId" type="text" value="40529289270" />
+        通道号:<input id="channel" type="text" value="2" />
+      </div>
+
+      <div class="controls">
+        <button id="nowPlay">实时播放9101</button>
+        码流:
+        <select id="nowDataRate">
+          <option value="1">子码流</option>
+          <option value="0">主码流</option>
+        </select>
+        音视频类型:
+        <select id="nowDataType">
+          <option value="0">音视频</option>
+          <option value="1">视频</option>
+        </select>
+      </div>
+
+      <div class="controls">
+        <button id="nowControll">实时控制9102</button>
+        控制指令:
+        <!--0 关闭音视频,1 切换码流 , 2 暂停该通道所有流的传输 ,3 恢复该通道所有流的传输 ,4 关闭双向对讲-->
+        <select id="nowControllOrder">
+          <option value="0">关闭音视频</option>
+          <option value="1">切换码流</option>
+        </select>
+        关闭类型:
+        <!--0 关闭音视频  ,1 只关闭音频,2只关闭视频-->
+        <select id="audioVideoType">
+          <option value="0">关闭音视频</option>
+          <option value="1">只关闭音频</option>
+          <option value="2">只关闭视频</option>
+        </select>
+        码流:
+        <!--码流类型,0:主码流,1:子码流-->
+        <select id="controllDataRate">
+          <option value="0">主码流</option>
+          <option value="1">子码流</option>
+        </select>
+      </div>
+
+      <div class="controls">
+        <button id="hisOrder">录像回放9201</button>
+        开始时间:
+        <input id="start" type="text" value="2023-08-12 08:00:00" />
+        结束时间:
+        <input id="end" type="text" value="2023-08-12 23:00:00" />
+        <!--回放方式0:正常回放;1:快进回放;2:关键帧快退回放;3:关键帧播放;4:单帧上传-->
+        回放方式:
+        <select id="hisPlayback">
+          <option value="0">正常回放</option>
+          <option value="1">快进回放</option>
+          <option value="2">关键帧快退回放</option>
+          <option value="3">关键帧播放</option>
+          <option value="4">单帧上传</option>
+        </select>
+        倍数:
+        <!--回放方式为1和2时,此字段内容有效,否则置0。0:无效;1:1 倍;2:2倍;3:4倍;4:8倍;5:16倍-->
+        <select id="hisFastTimes">
+          <option value="0">1倍</option>
+          <option value="2">2倍</option>
+          <option value="3">4倍</option>
+          <option value="4">8倍</option>
+          <option value="5">16倍</option>
+        </select>
+      </div>
+
+      <div class="controls">
+        <button id="hisControl">回放控制9202</button>
+        <!--回放控制方式,0:开始回放;1:暂停回放;2:结束回放;3:快进回放;4:关键帧快退回放;5:拖动回放;6:关键帧播放-->
+        回放方式:
+        <select name="" id="hisControlPlayback">
+          <option value="0">开始回放</option>
+          <option value="1">暂停回放</option>
+          <option value="2">结束回放</option>
+          <option value="3">快进回放</option>
+          <option value="4">关键帧快退回放</option>
+          <option value="5">拖动回放</option>
+          <option value="6">关键帧播放</option>
+        </select>
+        倍数:
+        <select id="hisControlFastTimes">
+          <option value="1">1倍</option>
+          <option value="2">2倍</option>
+          <option value="3">4倍</option>
+          <option value="4">8倍</option>
+          <option value="5">16倍</option>
+        </select>
+        跳转时间:
+        <input id="hisControlTime" type="text" value="2023-08-12 08:30:00" />
+      </div>
+
+      <div class="controls">
+        url:<input
+          style="width: 500px"
+          type="text"
+          id="playurl"
+          autofocus="autofocus"
+        />
+        当前播放的信息: 设备Id:<span id="curDeviceId"></span> 通道号:
+        <span id="curChannel"></span>
+      </div>
+      <div class="mainContainer">
+        <video id="videoElement" class="centeredVideo" controls>
+          Your browser is too old which doesn't support HTML5 video.
+        </video>
+      </div>
+
+      <hr />
+      <div class="controls">
+        第二个独立播放器:<input
+          style="width: 400px"
+          type="text"
+          id="otherPlayurl"
+          autofocus="autofocus"
+        />
+        <button id="otherPlay">播放</button> |
+        <button id="destroyOther">销毁</button>
+      </div>
+      <div class="mainContainer">
+        <video id="otherVideoElement" class="centeredVideo" controls>
+          Your browser is too old which doesn't support HTML5 video.
+        </video>
+      </div>
+    </div>
+  </body>
+</html>

+ 327 - 0
flv/indexcontroller.js

@@ -0,0 +1,327 @@
+$(document).ready(function () {
+  let token =
+    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb21wYW55SWQiOiI1MDc0NDY2NjU1NjUyNDU0NDAiLCJsb2dpbk5hbWUiOiJhZG1pbiIsImN1cnJlbnRUaW1lTWlsbGlzIjoiMTY4MTU2OTMzNTI3MiIsImV4cCI6MTY4MTU3NjUzNSwidXNlcklkIjoiNTEzNjA0MzE2MTQ1NzE3MjQ4In0.xSg5C0tqCQfDbKnHHLKMGPgWa9k3dnfb5QmpJSOG-tg";
+
+  function login() {
+    var domain = $("#domain").val();
+    var loginName = $("#loginName").val();
+    var pass = $("#pass").val();
+    //  var password = $.base64.encode(pass);
+    var password = pass;
+    $.post(
+      domain + "/system/login",
+      { loginName: loginName, password: password, type: 1 },
+      function (data, status) {
+        if (status == "success") {
+          if (data.errorCode == 0) {
+            token = data.data;
+          } else {
+            alert(data.desc);
+          }
+        }
+      }
+    );
+  }
+
+  login();
+
+  function nowPlay() {
+    var domain = $("#domain").val();
+    var deviceId = $("#deviceId").val();
+    var channel = $("#channel").val();
+
+    var nowDataRate = $("#nowDataRate").val();
+    var nowDataType = $("#nowDataType").val();
+
+    $.ajax(domain + "/core/Jtt808Order/videoStart", {
+      type: "post",
+      dataType: "json",
+      contentType: "application/json",
+      data: JSON.stringify({
+        channel: channel,
+        deviceId: deviceId,
+        dataRate: nowDataRate,
+        dataType: nowDataType,
+      }),
+      headers: { Authorization: token },
+      success: function (data, status) {
+        if (status == "success") {
+          if (data.errorCode == 0) {
+            $("#curDeviceId").html(deviceId);
+            $("#curChannel").html(channel);
+            var playurl =
+              domain +
+              "/video/now/" +
+              deviceId +
+              "-" +
+              channel +
+              "/time1681547649168";
+            $("#playurl").val(playurl);
+            //alert("实时播放");
+            play();
+          } else {
+            alert(data.desc);
+          }
+        }
+      },
+    });
+  }
+
+  function nowControll() {
+    var domain = $("#domain").val();
+    var deviceId = $("#deviceId").val();
+    var channel = $("#channel").val();
+
+    var nowControllOrder = $("#nowControllOrder").val();
+    var audioVideoType = $("#audioVideoType").val();
+    var controllDataRate = $("#controllDataRate").val();
+
+    $.ajax(domain + "/core/Jtt808Order/videoControl", {
+      type: "post",
+      dataType: "json",
+      contentType: "application/json",
+      data: JSON.stringify({
+        channel: channel,
+        deviceId: deviceId,
+        controll: nowControllOrder,
+        audioVideoType: audioVideoType,
+        dataRate: controllDataRate,
+      }),
+      headers: { Authorization: token },
+      success: function (data, status) {
+        if (status == "success") {
+          if (data.errorCode == 0) {
+            // 0 关闭音视频,1 切换码流 , 2 暂停该通道所有流的传输 ,3 恢复该通道所有流的传输 ,4 关闭双向对讲
+            if (nowControllOrder == 0) {
+              alert("关闭音视频");
+              close();
+            } else if (nowControllOrder == 1) {
+              //alert("切换码流");
+              var playurl = $("#playurl").val();
+              switchURL(playurl);
+            }
+          } else {
+            alert(data.desc);
+          }
+        }
+      },
+    });
+  }
+
+  function hisOrder() {
+    var domain = $("#domain").val();
+    var deviceId = $("#deviceId").val();
+    var channel = $("#channel").val();
+    var start = $("#start").val();
+    var end = $("#end").val();
+
+    var hisPlayback = $("#hisPlayback").val();
+    var hisFastTimes = $("#hisFastTimes").val();
+
+    $.ajax(domain + "/core/Jtt808Order/videoHis", {
+      type: "post",
+      dataType: "json",
+      contentType: "application/json",
+      data: JSON.stringify({
+        channel: channel,
+        dataRate: 0,
+        dataType: 0,
+        deviceId: deviceId,
+        startTime: start,
+        endTime: end,
+        fastTimes: hisFastTimes,
+        playback: hisPlayback,
+        storageType: 0,
+      }),
+      headers: { Authorization: token },
+      success: function (data, status) {
+        if (status == "success") {
+          if (data.errorCode == 0) {
+            var playurl =
+              domain +
+              "/video/history/" +
+              deviceId +
+              "-" +
+              channel +
+              "/time1681547649168";
+            $("#playurl").val(playurl);
+            close();
+            play();
+
+            $("#curDeviceId").html(deviceId);
+            $("#curChannel").html(channel);
+          } else {
+            alert(data.desc);
+          }
+        }
+      },
+    });
+  }
+
+  function hisControl() {
+    var domain = $("#domain").val();
+    var deviceId = $("#deviceId").val();
+    var channel = $("#channel").val();
+    // 回放控制方式,0:开始回放;1:暂停回放;2:结束回放;3:快进回放;4:关键帧快退回放;5:拖动回放;6:关键帧播放
+    var hisControlPlayback = $("#hisControlPlayback").val();
+    var hisControlFastTimes = $("#hisControlFastTimes").val();
+    var hisControlTime = $("#hisControlTime").val();
+
+    $.ajax(domain + "/core/Jtt808Order/videoHisControl", {
+      type: "post",
+      dataType: "json",
+      contentType: "application/json",
+      data: JSON.stringify({
+        deviceId: deviceId,
+        channel: channel,
+        playback: hisControlPlayback,
+        fastTimes: hisControlFastTimes,
+        curTime: hisControlTime,
+      }),
+      headers: { Authorization: token },
+      success: function (data, status) {
+        if (status == "success") {
+          if (data.errorCode == 0) {
+            if (hisControlPlayback == 5) {
+              alert("拖动回放");
+              close();
+              play();
+            } else if (hisControlPlayback == 2) {
+              alert("结束回放");
+              close();
+            } else if (hisControlPlayback == 3) {
+              alert("快进回放");
+              close();
+              play();
+            }
+          } else {
+            alert(data.desc);
+          }
+        }
+      },
+    });
+  }
+
+  var flvPlayer;
+
+  function close() {
+    if (flvPlayer != null) {
+      console.log("close");
+      flvPlayer.pause(); //暂停播放数据流
+
+      flvPlayer.unload(); //取消数据流加载
+      flvPlayer.detachMediaElement(); //将播放实例从节点中取出
+      flvPlayer.destroy(); //销毁播放实例
+    }
+  }
+
+  function replay() {
+    if (flvPlayer != null) {
+      //flvPlayer.pause(); //暂停播放数据流
+      //flvPlayer.unload(); //取消数据流加载
+      //flvPlayer.load({ reset: true }); //加载
+      //flvPlayer.play();
+      // close();
+      // play();
+    } else {
+      play();
+    }
+  }
+
+  function play() {
+    var playurl = $("#playurl").val();
+    if (playurl != null && playurl != "") {
+      var player = document.getElementById("videoElement");
+
+      if (flvjs.isSupported()) {
+        flvPlayer = flvjs.createPlayer({
+          isLive: true,
+          type: "flv",
+          url: playurl,
+          // 是否启用 worker,开启后会使用 web worker 解析数据,提高性能
+          //enableWorker: true,
+          // 是否启用媒体源缓存功能
+          enableStashBuffer: false,
+          stashInitialSize: 128, // 减少首桢显示等待时长
+        });
+
+        flvPlayer.attachMediaElement(player);
+        flvPlayer.load(); //加载
+        flvPlayer.play();
+      }
+    }
+  }
+
+  var otherFlvPlayer;
+  function otherPlay() {
+    var otherPlayurl = $("#otherPlayurl").val();
+    if (otherPlayurl != null && otherPlayurl != "") {
+      var player = document.getElementById("otherVideoElement");
+
+      if (flvjs.isSupported()) {
+        otherFlvPlayer = flvjs.createPlayer({
+          isLive: true,
+          type: "flv",
+          url: otherPlayurl,
+          // 是否启用 worker,开启后会使用 web worker 解析数据,提高性能
+          //enableWorker: true,
+          // 是否启用媒体源缓存功能
+          enableStashBuffer: false,
+          stashInitialSize: 128, // 减少首桢显示等待时长
+        });
+
+        otherFlvPlayer.attachMediaElement(player);
+        otherFlvPlayer.load(); //加载
+        otherFlvPlayer.play();
+      }
+    }
+  }
+
+  function destroyOther() {
+    if (otherFlvPlayer != null) {
+      console.log("destroyOther");
+      otherFlvPlayer.pause(); //暂停播放数据流
+
+      otherFlvPlayer.unload(); //取消数据流加载
+      otherFlvPlayer.detachMediaElement(); //将播放实例从节点中取出
+      otherFlvPlayer.destroy(); //销毁播放实例
+      otherFlvPlayer = null;
+    }
+  }
+
+  $("#login").click(function () {
+    login();
+  });
+
+  $("#nowPlay").click(function () {
+    nowPlay();
+  });
+
+  $("#nowControll").click(function () {
+    nowControll();
+  });
+
+  $("#hisOrder").click(function () {
+    hisOrder();
+  });
+
+  $("#hisControl").click(function () {
+    hisControl();
+  });
+
+  $("#close").click(function () {
+    close();
+  });
+
+  $("#play").click(function () {
+    play();
+  });
+
+  $("#otherPlay").click(function () {
+    otherPlay();
+  });
+
+  $("#destroyOther").click(function () {
+    destroyOther();
+  });
+});

+ 146 - 0
flv/jquery.base64.js

@@ -0,0 +1,146 @@
+/*!
+ * jquery.base64.js 0.1 - https://github.com/yckart/jquery.base64.js
+ * Makes Base64 en & -decoding simpler as it is.
+ *
+ * Based upon: https://gist.github.com/Yaffle/1284012
+ *
+ * Copyright (c) 2012 Yannick Albert (http://yckart.com)
+ * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
+ * 2013/02/10
+ **/
+(function ($) {
+  var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
+    a256 = "",
+    r64 = [256],
+    r256 = [256],
+    i = 0;
+
+  var UTF8 = {
+    /**
+     * Encode multi-byte Unicode string into utf-8 multiple single-byte characters
+     * (BMP / basic multilingual plane only)
+     *
+     * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
+     *
+     * @param {String} strUni Unicode string to be encoded as UTF-8
+     * @returns {String} encoded string
+     */
+    encode: function (strUni) {
+      // use regular expressions & String.replace callback function for better efficiency
+      // than procedural approaches
+      var strUtf = strUni
+        .replace(
+          /[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
+          function (c) {
+            var cc = c.charCodeAt(0);
+            return String.fromCharCode(0xc0 | (cc >> 6), 0x80 | (cc & 0x3f));
+          }
+        )
+        .replace(
+          /[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
+          function (c) {
+            var cc = c.charCodeAt(0);
+            return String.fromCharCode(
+              0xe0 | (cc >> 12),
+              0x80 | ((cc >> 6) & 0x3f),
+              0x80 | (cc & 0x3f)
+            );
+          }
+        );
+      return strUtf;
+    },
+
+    /**
+     * Decode utf-8 encoded string back into multi-byte Unicode characters
+     *
+     * @param {String} strUtf UTF-8 string to be decoded back to Unicode
+     * @returns {String} decoded string
+     */
+    decode: function (strUtf) {
+      // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
+      var strUni = strUtf
+        .replace(
+          /[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
+          function (c) {
+            // (note parentheses for precence)
+            var cc =
+              ((c.charCodeAt(0) & 0x0f) << 12) |
+              ((c.charCodeAt(1) & 0x3f) << 6) |
+              (c.charCodeAt(2) & 0x3f);
+            return String.fromCharCode(cc);
+          }
+        )
+        .replace(
+          /[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
+          function (c) {
+            // (note parentheses for precence)
+            var cc = ((c.charCodeAt(0) & 0x1f) << 6) | (c.charCodeAt(1) & 0x3f);
+            return String.fromCharCode(cc);
+          }
+        );
+      return strUni;
+    },
+  };
+
+  while (i < 256) {
+    var c = String.fromCharCode(i);
+    a256 += c;
+    r256[i] = i;
+    r64[i] = b64.indexOf(c);
+    ++i;
+  }
+
+  function code(s, discard, alpha, beta, w1, w2) {
+    s = String(s);
+    var buffer = 0,
+      i = 0,
+      length = s.length,
+      result = "",
+      bitsInBuffer = 0;
+
+    while (i < length) {
+      var c = s.charCodeAt(i);
+      c = c < 256 ? alpha[c] : -1;
+
+      buffer = (buffer << w1) + c;
+      bitsInBuffer += w1;
+
+      while (bitsInBuffer >= w2) {
+        bitsInBuffer -= w2;
+        var tmp = buffer >> bitsInBuffer;
+        result += beta.charAt(tmp);
+        buffer ^= tmp << bitsInBuffer;
+      }
+      ++i;
+    }
+    if (!discard && bitsInBuffer > 0)
+      result += beta.charAt(buffer << (w2 - bitsInBuffer));
+    return result;
+  }
+
+  var Plugin = ($.base64 = function (dir, input, encode) {
+    return input ? Plugin[dir](input, encode) : dir ? null : this;
+  });
+
+  Plugin.btoa = Plugin.encode = function (plain, utf8encode) {
+    plain =
+      Plugin.raw === false || Plugin.utf8encode || utf8encode
+        ? UTF8.encode(plain)
+        : plain;
+    plain = code(plain, false, r256, b64, 8, 6);
+    return plain + "====".slice(plain.length % 4 || 4);
+  };
+
+  Plugin.atob = Plugin.decode = function (coded, utf8decode) {
+    coded = String(coded).split("=");
+    var i = coded.length;
+    do {
+      --i;
+      coded[i] = code(coded[i], true, r64, a256, 6, 8);
+    } while (i > 0);
+    coded = coded.join("");
+    return Plugin.raw === false || Plugin.utf8decode || utf8decode
+      ? UTF8.decode(coded)
+      : coded;
+  };
+})(jQuery);

Some files were not shown because too many files changed in this diff