Browse Source

修改广播的文字,增加查询服务器地址的接口

vothin 3 years ago
parent
commit
09a0c1622c
5 changed files with 90 additions and 29 deletions
  1. 11 1
      languages/en.js
  2. 11 1
      languages/zh-CN.js
  3. 1 2
      src/api/calling-broadcast.js
  4. 10 0
      src/api/ncs_service_info.js
  5. 57 25
      src/views/ncs-broadcast/index.vue

+ 11 - 1
languages/en.js

@@ -48,6 +48,10 @@ module.exports = {
     updateTime: 'Update time',
     updateTime: 'Update time',
     save: 'Save',
     save: 'Save',
     saveSuccess: 'Save successfully! ',
     saveSuccess: 'Save successfully! ',
+    saveFailed: 'Save failed! ',
+    saveAgain: 'Reconnect, please click Save again! ',
+    systemNoReturnMessage: 'The system has no return message!',
+    failedGetReturnMessage: 'Failed to get the return message!',
     notDevelopedYet: 'Not yet developed',
     notDevelopedYet: 'Not yet developed',
     keywords: 'Please enter a search keyword',
     keywords: 'Please enter a search keyword',
     chooseLang: 'Choose language',
     chooseLang: 'Choose language',
@@ -553,12 +557,18 @@ module.exports = {
     repeatDay: 'Start Day',
     repeatDay: 'Start Day',
     play: 'Play',
     play: 'Play',
     stop: 'Stop',
     stop: 'Stop',
+    playManually: 'Play manually',
+    audition: 'Audition',
+    playbackSuccessful: 'Playback successful',
+    auditionEnd: 'End of audition',
     playOrder: 'Play order',
     playOrder: 'Play order',
     playOrderMsg: 'Playing order is required',
     playOrderMsg: 'Playing order is required',
     broadcastFrameGroup: 'Broadcast area',
     broadcastFrameGroup: 'Broadcast area',
     otherBroadcastFrameGroup: 'Other broadcast positions',
     otherBroadcastFrameGroup: 'Other broadcast positions',
     broadcastInfo: 'Broadcast information',
     broadcastInfo: 'Broadcast information',
-    broadcastFile: 'Broadcast file'
+    broadcastFile: 'Broadcast file',
+    broadcastLoadFailed: 'Failed to load broadcast plug-in! ',
+    broadPlugInError: 'Broadcast plug-in error: '
   },
   },
   event: {
   event: {
     eventEdit: 'Edit button event',
     eventEdit: 'Edit button event',

+ 11 - 1
languages/zh-CN.js

@@ -49,6 +49,10 @@ module.exports = {
     updateTime: '更新时间',
     updateTime: '更新时间',
     save: '保存',
     save: '保存',
     saveSuccess: '保存成功!',
     saveSuccess: '保存成功!',
+    saveFailed: '保存失败',
+    saveAgain: '重新连接,请再次点击保存',
+    systemNoReturnMessage: '系统无返回消息!',
+    failedGetReturnMessage: '未能得到返回消息!',
     notDevelopedYet: '暂未开发',
     notDevelopedYet: '暂未开发',
     keywords: '请输入搜索关键字',
     keywords: '请输入搜索关键字',
     chooseLang: '选择语言',
     chooseLang: '选择语言',
@@ -555,12 +559,18 @@ module.exports = {
     repeatDay: '开启日',
     repeatDay: '开启日',
     play: '播放',
     play: '播放',
     stop: '停止',
     stop: '停止',
+    playManually: '手动播放',
+    audition: '试听',
+    auditionEnd: '试听结束',
+    playbackSuccessful: '播放成功',
     playOrder: '播放顺序',
     playOrder: '播放顺序',
     playOrderMsg: '播放顺序必填',
     playOrderMsg: '播放顺序必填',
     broadcastFrameGroup: '广播区域',
     broadcastFrameGroup: '广播区域',
     otherBroadcastFrameGroup: '其他广播位置',
     otherBroadcastFrameGroup: '其他广播位置',
     broadcastInfo: '广播信息',
     broadcastInfo: '广播信息',
-    broadcastFile: '广播文件'
+    broadcastFile: '广播文件',
+    broadcastLoadFailed: '加载广播插件失败',
+    broadPlugInError: '广播插件错误:'
   },
   },
   event: {
   event: {
     eventEdit: '编辑按钮事件',
     eventEdit: '编辑按钮事件',

+ 1 - 2
src/api/calling-broadcast.js

@@ -1,5 +1,5 @@
 import request from '@/utils/request'
 import request from '@/utils/request'
-import {mediaRequest} from "../utils/request";
+import { mediaRequest } from '../utils/request'
 
 
 /**
 /**
  * 广播设置相关接口
  * 广播设置相关接口
@@ -56,7 +56,6 @@ export function get(id, params) {
   })
   })
 }
 }
 
 
-
 /** 查询某科室下的指定区域广播信息 */
 /** 查询某科室下的指定区域广播信息 */
 export function getBoardCast(partid, zoneIndex) {
 export function getBoardCast(partid, zoneIndex) {
   return request({
   return request({

+ 10 - 0
src/api/ncs_service_info.js

@@ -0,0 +1,10 @@
+import request from '@/utils/request'
+
+/** 服务器配置 */
+export function getServiceInfo() {
+  return request({
+    url: `/ncs_url/server_info`,
+    method: 'get',
+    loading: false
+  })
+}

+ 57 - 25
src/views/ncs-broadcast/index.vue

@@ -37,7 +37,7 @@
       />
       />
     </ag-grid-layout>
     </ag-grid-layout>
 
 
-    <el-dialog title="手动播放" width="300" :visible="manulPlay" :show-close="false">
+    <el-dialog :title="this.$t('broadcast.playManually')" width="300" :visible="manulPlay" :show-close="false">
       <el-row>
       <el-row>
         <el-col :span="24">
         <el-col :span="24">
           {{auditionTotalMsg}}
           {{auditionTotalMsg}}
@@ -52,11 +52,11 @@
         <el-progress :show-text="false" :text-inside="true" :stroke-width="30" :percentage="auditionPositionPercent" status="success"></el-progress>
         <el-progress :show-text="false" :text-inside="true" :stroke-width="30" :percentage="auditionPositionPercent" status="success"></el-progress>
       </el-row>
       </el-row>
       <span slot="footer" class="dialog-footer">
       <span slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="stopBroadcast(currentRow)">停止</el-button>
+        <el-button type="primary" @click="stopBroadcast(currentRow)">{{ this.$t('broadcast.stop') }}</el-button>
       </span>
       </span>
     </el-dialog>
     </el-dialog>
 
 
-    <el-dialog title="试听" width="300" :visible="stream!==null" :show-close="false">
+    <el-dialog :title="this.$t('broadcast.audition')" width="300" :visible="stream!==null" :show-close="false">
       <el-row>
       <el-row>
         <el-col :span="24">
         <el-col :span="24">
           {{auditionTotalMsg}}
           {{auditionTotalMsg}}
@@ -74,7 +74,7 @@
         <audio ref="audio" loop autoplay playsinline :srcObject.prop="stream" v-if="stream" style="width: 300px;height:100px;"></audio>
         <audio ref="audio" loop autoplay playsinline :srcObject.prop="stream" v-if="stream" style="width: 300px;height:100px;"></audio>
       </div>
       </div>
       <span slot="footer" class="dialog-footer">
       <span slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="streamingStop(true)">停止</el-button>
+        <el-button type="primary" @click="streamingStop(true)">{{ this.$t('broadcast.stop') }}</el-button>
       </span>
       </span>
     </el-dialog>
     </el-dialog>
 
 
@@ -205,6 +205,7 @@
 import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
 import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
 import ButtonCellRenderList from '@/components/AgGridCellRender/ButtonCellRenderList'
 import ButtonCellRenderList from '@/components/AgGridCellRender/ButtonCellRenderList'
 import * as API_Broadcast from '@/api/calling-broadcast'
 import * as API_Broadcast from '@/api/calling-broadcast'
+import * as API_ServiceInfo from '@/api/ncs_service_info'
 import { unix2Date } from '@/utils/Foundation'
 import { unix2Date } from '@/utils/Foundation'
 import * as API_FrameGroup from '@/api/ncs_frameGroup'
 import * as API_FrameGroup from '@/api/ncs_frameGroup'
 import ListFilter from '@/components/AgGridCustomFilter/ListFilter'
 import ListFilter from '@/components/AgGridCustomFilter/ListFilter'
@@ -229,7 +230,8 @@ export default {
   components: { ButtonCellRenderList, ListFilter, RadioFilter },
   components: { ButtonCellRenderList, ListFilter, RadioFilter },
   data() {
   data() {
     return {
     return {
-      rtcServer: "ws://192.168.1.54:20022/janus",
+      // rtcServer: "ws://192.168.1.54:20022/janus",
+      rtcServer:  "",
       opaqueId: "streaming-"+randomString(12),
       opaqueId: "streaming-"+randomString(12),
       janus: null,  //实例
       janus: null,  //实例
       pluginHandle: null,   //插件
       pluginHandle: null,   //插件
@@ -409,7 +411,7 @@ export default {
                 buttonSize: 'mini',
                 buttonSize: 'mini',
                 disabled: param.data.broadcast_mode !== 1 || !param.data.status
                 disabled: param.data.broadcast_mode !== 1 || !param.data.status
               },{
               },{
-                label: '试听',
+                label: this.$t('broadcast.audition'),
                 buttonSize: 'mini',
                 buttonSize: 'mini',
                 buttonType: 'success',
                 buttonType: 'success',
                 onClick: () => {
                 onClick: () => {
@@ -425,7 +427,7 @@ export default {
         filter: false,
         filter: false,
         pinned: 'right',
         pinned: 'right',
         lockPinned: true,
         lockPinned: true,
-        width: 290,
+        width: this.$i18n.locale === 'zh' ? 290 : 300,
         resizable: false,
         resizable: false,
         sortable: false
         sortable: false
       }
       }
@@ -457,21 +459,30 @@ export default {
       ]
       ]
     })
     })
     this.getAllFrameGroups()
     this.getAllFrameGroups()
+    if (this.rtcServer === null || this.rtcServer === "") {
+      this.getRtcServer()
+    }
 
 
     this.initAuditionWebSocket()
     this.initAuditionWebSocket()
-    Janus.init({
-      debug: false,
-      dependencies: Janus.useDefaultDependencies(),
-      callback: () => {
-        this.connect(this.rtcServer)
-      }
-    })
+    // Janus.init({
+    //   debug: false,
+    //   dependencies: Janus.useDefaultDependencies(),
+    //   callback: () => {
+    //     if (this.rtcServer !== null && this.rtcServer !== "") {
+    //       this.connect(this.rtcServer)
+    //     }
+    //   }
+    // })
 
 
     const _this = this
     const _this = this
     //每分钟检查一次websocket状态,如果掉线,则重连
     //每分钟检查一次websocket状态,如果掉线,则重连
     setInterval(function() {
     setInterval(function() {
       if (_this.janus === null) {
       if (_this.janus === null) {
-        _this.connect(this.rtcServer)
+        if (_this.rtcServer !== null && _this.rtcServer !== "") {
+          _this.connect(this.rtcServer)
+        } else {
+          this.getRtcServer()
+        }
       }
       }
       if (_this.websock === null) {
       if (_this.websock === null) {
         _this.initAuditionWebSocket()
         _this.initAuditionWebSocket()
@@ -524,7 +535,7 @@ export default {
         } else {
         } else {
           this.$message({
           this.$message({
             type: 'success',
             type: 'success',
-            message: '播放成功'
+            message: this.$t('broadcast.playbackSuccessful')
           })
           })
           row.playing = true
           row.playing = true
           this.gridApi.redrawRows()
           this.gridApi.redrawRows()
@@ -697,8 +708,12 @@ export default {
           this.formmodel.part_id = this.$store.getters.partId
           this.formmodel.part_id = this.$store.getters.partId
           //判断 janus 是否连接状态
           //判断 janus 是否连接状态
           if (this.janus === null) {
           if (this.janus === null) {
-            this.connect(this.rtcServer)
-            this.$message.error('重新连接,请再次点击保存')
+            if (this.rtcServer === null || this.rtcServer === ""){
+              this.getRtcServer()
+            } else {
+              this.connect(this.rtcServer)
+            }
+            this.$message.error(this.$t('action.saveAgain'))
             return
             return
           }
           }
 
 
@@ -708,7 +723,7 @@ export default {
               if (result.id) {
               if (result.id) {
                 this.createStreaming(result.id, result.audio_port);
                 this.createStreaming(result.id, result.audio_port);
               } else {
               } else {
-                this.$message.error('保存失败')
+                this.$message.error(this.$t('action.saveFailed'))
                 return
                 return
               }
               }
             } else {
             } else {
@@ -806,7 +821,7 @@ export default {
         this.streamingStop(false)
         this.streamingStop(false)
         this.$message({
         this.$message({
           type: 'success',
           type: 'success',
-          message: '试听结束'
+          message: this.$t('broadcast.auditionEnd')
         })
         })
       }
       }
     },
     },
@@ -836,8 +851,8 @@ export default {
           this.attachPlugin()
           this.attachPlugin()
         },
         },
         error: (error) => {
         error: (error) => {
-          console.log('加载广播插件失败', error)
-          _this.$alert('加载广播插件失败','系统提示',{
+          console.log(this.$t('broadcast.broadcastLoadFailed'), error)
+          _this.$alert(this.$t('broadcast.broadcastLoadFailed'), this.$t('action.systemPrompt'),{
             confirmButtonText: this.$t('action.yes'),
             confirmButtonText: this.$t('action.yes'),
             callback: action => {
             callback: action => {
               _this.janus = null
               _this.janus = null
@@ -862,7 +877,7 @@ export default {
           },
           },
           error: function(error) {
           error: function(error) {
             console.log("  -- Error attaching plugin... ", error)
             console.log("  -- Error attaching plugin... ", error)
-            this.$alert('广播插件错误:' + error,'系统提示')
+            this.$alert(this.$t('broadcast.broadPlugInError') + error, this.$t('action.systemPrompt'))
           },
           },
           iceState: function(state) {
           iceState: function(state) {
             console.log("ICE state changed to " + state)
             console.log("ICE state changed to " + state)
@@ -969,7 +984,7 @@ export default {
 // streaming: "created"
 // streaming: "created"
           console.log('result===', result)
           console.log('result===', result)
           if(!result) {
           if(!result) {
-            _this.$alert('系统无返回消息!', '系统提示', {
+            _this.$alert(this.$t('action.systemNoReturnMessage'), this.$t('action.systemPrompt'), {
               confirmButtonText: this.$t('action.yes'),
               confirmButtonText: this.$t('action.yes'),
               callback: action => {
               callback: action => {
               }
               }
@@ -994,7 +1009,7 @@ export default {
         if(!result) {
         if(!result) {
           _this.$message({
           _this.$message({
             type: 'error',
             type: 'error',
-            message: '未能得到返回消息!'
+            message: this.$t('action.failedGetReturnMessage')
           })
           })
           return;
           return;
         }
         }
@@ -1024,6 +1039,23 @@ export default {
     },
     },
     onCleanup() {
     onCleanup() {
       this.stream = null
       this.stream = null
+    },
+    getRtcServer() {
+      API_ServiceInfo.getServiceInfo().then(r => {
+        const result = r
+        console.log("result", result)
+        this.rtcServer = "ws://" +  r.rtc_public_ip + ":" + r.rtc_port + "/janus"
+
+        Janus.init({
+          debug: false,
+          dependencies: Janus.useDefaultDependencies(),
+          callback: () => {
+            if (this.rtcServer !== null && this.rtcServer !== "") {
+              this.connect(this.rtcServer)
+            }
+          }
+        })
+      })
     }
     }
   }
   }
 }
 }