Quellcode durchsuchen

flv播放优化

zhangjie vor 2 Jahren
Ursprung
Commit
11a6333d52

+ 26 - 1
src/features/invigilation/common/FlvMedia.vue

@@ -58,6 +58,7 @@ export default {
         error: false,
         message: "",
       },
+      lastDecodedFrames: 0,
     };
   },
   watch: {
@@ -75,7 +76,13 @@ export default {
   methods: {
     initVideo() {
       if (!this.liveUrl) return;
-      if (!flvjs.isSupported()) return;
+      if (!flvjs.isSupported()) {
+        this.result = {
+          error: true,
+          message: "不支持播放",
+        };
+        return;
+      }
       this.loading = true;
 
       this.flvPlayer = flvjs.createPlayer(
@@ -96,8 +103,26 @@ export default {
       this.flvPlayer.on(flvjs.Events.ERROR, this.playError);
       this.flvPlayer.on(flvjs.Events.METADATA_ARRIVED, () => {
         this.loading = false;
+        console.log("正常播放");
         this.retryCount = 0;
       });
+      this.flvPlayer.on(
+        flvjs.Events.STATISTICS_INFO,
+        this.statisticsInfoEventHandle
+      );
+    },
+    statisticsInfoEventHandle(res) {
+      if (this.lastDecodedFrames === 0) {
+        this.lastDecodedFrames = res.decodedFrames;
+        return;
+      }
+      if (this.lastDecodedFrames !== res.decodedFrames) {
+        this.lastDecodedFrames = res.decodedFrames;
+      } else {
+        this.lastDecodedFrames = 0;
+        console.log("卡住了,准备重试!");
+        this.retryPlay();
+      }
     },
     playError(errorType) {
       switch (errorType) {

+ 5 - 2
src/features/system/DataStatistics/DataStatistics.vue

@@ -103,12 +103,15 @@ export default {
 
       this.addSetTime(this.getData, 10 * 1000);
     },
+    transformAreaName(name) {
+      return name.replace("省", "").replace("市", "");
+    },
     getInviMapOption(dataList) {
       // if (!dataList.length) return;
 
       let countData = dataList.map((item) => {
         return {
-          name: item.province,
+          name: this.transformAreaName(item.province),
           ...item,
           itemStyle: {
             areaColor: "rgba(45, 153, 255, 0.5)",
@@ -141,7 +144,7 @@ export default {
           },
           backgroundColor: "rgba(63,67,87,0.9)",
           padding: 10,
-          triggerOn: "click",
+          // triggerOn: "click",
           textStyle: {
             fontSize: 12,
             color: "#E1E6EF",