Ver Fonte

鸟瞰图 - 区域详情页面设备视频播放功能
鸟瞰图 - 设备视频页面上传功能优化

wangggziwen há 2 meses atrás
pai
commit
c966856163

+ 19 - 0
master/src/main/java/com/ruoyi/config/web/WebConfig.java

@@ -0,0 +1,19 @@
+package com.ruoyi.config.web;
+
+import com.ruoyi.framework.config.RuoYiConfig;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        /**
+         * 资源映射路径
+         * addResourceHandler:访问映射路径
+         * addResourceLocations:资源绝对路径
+         */
+        registry.addResourceHandler("/devVideo/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/devVideo/");
+    }
+}

+ 1 - 0
master/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -119,6 +119,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/*/api-docs").anonymous()
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/static/**").anonymous()
+                .antMatchers("/devVideo/**").anonymous()
                 .antMatchers("/common/template").anonymous()
                 .antMatchers("/plant/generatereport/export").anonymous()
                 .antMatchers("/plant/meeting/meetingReport").anonymous()

+ 6 - 3
master/src/main/java/com/ruoyi/project/aerial/controller/TAerialDevVideoController.java

@@ -20,6 +20,7 @@ import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.web.page.TableDataInfo;
 import org.springframework.web.multipart.MultipartFile;
+import sun.misc.ObjectInputFilter;
 
 /**
  * 鸟瞰图设备视频Controller
@@ -52,12 +53,14 @@ public class TAerialDevVideoController extends BaseController
             commonfile.setpId(video.getId());
             List<TCommonfile> tCommonfiles = tCommonfileService.selectAllFileList(commonfile);//文件列表
             if (tCommonfiles.size() == 1) {//最多一个文件
-                return AjaxResult.success(tCommonfiles.get(0));
+                TCommonfile file = tCommonfiles.get(0);
+                file.setFileUrl(file.getFileUrl().replace("/profile", ""));
+                return AjaxResult.success(file);
             } else {
-                return AjaxResult.error("");
+                return AjaxResult.success();
             }
         } else {
-            return AjaxResult.error("");
+            return AjaxResult.success();
         }
     }
 

+ 2 - 1
ui/package.json

@@ -54,8 +54,8 @@
     "@jiaminghi/data-view": "^2.10.0",
     "@popperjs/core": "^2.11.5",
     "@riophae/vue-treeselect": "0.4.0",
-    "bootstrap": "^4.5.0",
     "axios": "^0.21.1",
+    "bootstrap": "^4.5.0",
     "clipboard": "2.0.4",
     "core-js": "3.6.5",
     "dayjs": "^1.10.6",
@@ -86,6 +86,7 @@
     "vue-i18n": "7.3.2",
     "vue-router": "3.0.2",
     "vue-splitpane": "1.0.4",
+    "vue-video-player": "^5.0.1",
     "vuedraggable": "2.20.0",
     "vuex": "3.6.0"
   },

+ 8 - 0
ui/src/main.js

@@ -50,6 +50,14 @@ import throttle from "@/utils/throttle";
 import {download2} from "@/utils/request";
 Vue.prototype.$throttle = throttle;
 
+import VideoPlayer from 'vue-video-player'
+
+import 'video.js/dist/video-js.css'
+
+import 'vue-video-player/src/custom-theme.css'
+
+Vue.use(VideoPlayer)
+
 
 // 全局注册图标
 Vue.component('icon', Icon);

+ 72 - 37
ui/src/views/aerial/detail/index.vue

@@ -10,50 +10,58 @@
       :title="dialogTitle"
       :visible.sync="dialogVisible"
       width="80%">
-      <span>{{videoUrl}}</span>
-      <video-player  class="video-player vjs-custom-skin"
-                     ref="videoPlayer"
-                     :playsinline="true"
-                     :options="playerOptions"
-      ></video-player>
+      <div class="video-player-container">
+        <video-player
+          class="video-player"
+          ref="videoPlayer"
+          :playsinline="true"
+          :options="playerOptions"
+          style="width: 100%;"
+        ></video-player>
+      </div>
     </el-dialog>
   </div>
 </template>
 
 <script>
   import { getDevVideoByAreaAndDev } from "@/api/aerial/devVideo";
+  import { videoPlayer } from "vue-video-player";
 
   export default {
+    name: "",
+    components: {videoPlayer},
+    props: {},
     data() {
       return {
         areaName: '',
         dialogVisible: false,
         dialogTitle: '',
-        videoUrl: '',
-        // 视频播放
-        playerOptions : {
-          playbackRates : [ 0.5, 1.0, 1.5, 2.0 ], //可选择的播放速度
-          autoplay : false, //如果true,浏览器准备好时开始回放。
-          muted : false, // 默认情况下将会消除任何音频。
-          loop : false, // 视频一结束就重新开始。
-          preload : 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
-          language : 'zh-CN',
-          aspectRatio : '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
-          fluid : true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
-          sources : [ {
-            type : "",
-            src : 'http://www.html5videoplayer.net/videos/madagascar3.mp4'//url地址
-          } ],
-          poster : "", //你的封面地址
-          // width: document.documentElement.clientWidth,
-          notSupportedMessage : '此视频暂无法播放,请稍后再试', //允许覆盖Video.js无法播放媒体源时显示的默认信息。
-          controlBar : {
-            timeDivider : true,//当前时间和持续时间的分隔符
-            durationDisplay : true,//显示持续时间
-            remainingTimeDisplay : false,//是否显示剩余时间功能
-            fullscreenToggle : true  //全屏按钮
-          }
-        }
+        playerOptions: {
+          playbackRates: [0.5, 1.0, 1.5, 2.0],
+          autoplay: true,
+          muted: false,
+          loop: true,
+          preload: "auto",
+          language: "zh-CN",
+          aspectRatio: "16:9",
+          fluid: true,
+          sources: [
+            {
+              type: "video/mp4",
+              // src: "http://www.html5videoplayer.net/videos/madagascar3.mp4",
+              src: '',
+            },
+          ],
+          poster: "", // 封面地址
+          width: document.documentElement.clientWidth,
+          notSupportedMessage: "加载中......", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
+          controlBar: {
+            timeDivider: true, // 当前时间和持续时间的分隔符
+            durationDisplay: true, // 显示持续时间
+            remainingTimeDisplay: true, // 是否显示剩余时间功能
+            fullscreenToggle: true, // 是否显示全屏按钮
+          },
+        },
       }
     },
     created() {
@@ -61,16 +69,28 @@
     },
     methods: {
       handleDevClick(devName) {
+        this.playerOptions.sources = [
+          {
+            type: "video/mp4",
+            src: '',
+          },
+        ];
+        this.playerOptions.notSupportedMessage = '加载中......';
         getDevVideoByAreaAndDev({
           "areaName": this.areaName,
           "devName": devName,
         }).then(response => {
-          console.log(response.data.fileUrl)
-          this.videoUrl = response.data.fileUrl;
-          this.playerOptions.sources = [ {
-            type : "",
-            src : response.data.fileUrl
-          } ],
+          if (response.data != null && response.data != "") {
+            this.playerOptions.sources = [
+              {
+                type: "video/mp4",
+                src: 'http://localhost:8090'+ response.data.fileUrl,
+              },
+            ];
+          } else {
+            this.playerOptions.notSupportedMessage = '视频未上传......';
+          }
+
           this.dialogTitle = this.areaName + " - " + devName;
           this.dialogVisible = true;
         });
@@ -78,3 +98,18 @@
     }
   }
 </script>
+
+<style scoped>
+  /deep/.video-js .vjs-big-play-button {
+    width: 88px !important;
+    height: 88px !important;
+    border-radius: 50% !important;
+    border: 0;
+    line-height: 88px;
+    font-size: 56px;
+    object-fit: cover;
+    text-align: center;
+    background-color: rgba(0, 0, 0, 0.5);
+    display: none;
+  }
+</style>

+ 32 - 24
ui/src/views/aerial/video/index.vue

@@ -161,7 +161,7 @@
             type="text"
             @click="handleUpload(scope.row)"
             v-hasPermi="['aerial:devVideo:edit']"
-          >上传</el-button>
+          >查看</el-button>
         </template>
       </el-table-column>
       <!--<el-table-column label="部门id" align="center" prop="deptId" :show-overflow-tooltip="true"/>-->
@@ -250,29 +250,31 @@
     </el-dialog>
       <!-- 用户导入对话框 -->
       <el-dialog :title="upload.title" :visible.sync="upload.open" width="600px" append-to-body>
+        <div v-show="showUpload">
           <el-upload
-                  ref="upload"
-                  :limit="1"
-                  accept=".mp4, .ogg, .flv, .avi"
-                  :headers="upload.headers"
-                  :action="upload.url + '?pType=devVideo&pId=' + upload.pId"
-                  :disabled="upload.isUploading"
-                  :on-progress="handleFileUploadProgress"
-                  :on-success="handleFileSuccess"
-                  :auto-upload="true"
-                  drag
+            ref="upload"
+            :limit="1"
+            accept=".mp4, .ogg, .flv, .avi"
+            :headers="upload.headers"
+            :action="upload.url + '?pType=devVideo&pId=' + upload.pId"
+            :disabled="upload.isUploading"
+            :on-progress="handleFileUploadProgress"
+            :on-success="handleFileSuccess"
+            :auto-upload="true"
+            drag
           >
-              <i class="el-icon-upload"></i>
-              <div class="el-upload__text">
-                  将文件拖到此处,或
-                  <em>点击上传</em>
-              </div>
-              <!--<div class="el-upload__tip" slot="tip">-->
-                  <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
-                  <!--<el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>-->
-              <!--</div>-->
-              <!--<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>-->
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">
+              将文件拖到此处,或
+              <em>点击上传</em>
+            </div>
+            <!--<div class="el-upload__tip" slot="tip">-->
+            <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
+            <!--<el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>-->
+            <!--</div>-->
+            <!--<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>-->
           </el-upload>
+        </div>
           <el-table :data="upload.commonfileList" border>
             <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
               <template slot-scope="scope">
@@ -375,7 +377,8 @@ export default {
       form: {},
       // 表单校验
       rules: {
-      }
+      },
+      showUpload: true,
     };
   },
   watch: {
@@ -410,6 +413,11 @@ export default {
         "pType": this.upload.pType
       }).then(response => {
         this.upload.commonfileList = response;
+        if (response.length > 0) {
+          this.showUpload = false;
+        } else {
+          this.showUpload = true;
+        }
       });
     },
     // 文件下载处理
@@ -437,9 +445,9 @@ export default {
         this.msgSuccess(this.$t('删除成功'));
       })
     },
-    /** 上传按钮操作 */
+    /** 查看按钮操作 */
     handleUpload(row) {
-      this.upload.title = "设备视频文件上传" + "(" + row.areaName + " - " + row.devName + ")";
+      this.upload.title = "设备视频文件" + "(" + row.areaName + " - " + row.devName + ")";
       this.upload.pId = row.id;
       this.upload.commonfileList = null;
       this.getFileList();