Prechádzať zdrojové kódy

自动播放,手动播放 OK

allen 3 rokov pred
rodič
commit
7a715f8e82

+ 18 - 4
src/api/calling-broadcast.js

@@ -122,16 +122,30 @@ export function broadVol(params) {
   })
 }
 
-export function auditionStart(id, uuid) {
+export function manulStart(id) {
   return mediaRequest({
     method: 'get',
-    url: `/streaming/audition_start/${uuid}/${id}`
+    url: `/streaming/manul_start/${id}`
   })
 }
 
-export function auditionStop(uuid) {
+export function manulStop(part_id, id) {
   return mediaRequest({
     method: 'get',
-    url: `/streaming/audition_stop/${uuid}`
+    url: `/streaming/manul_stop/${part_id}/${id}`
+  })
+}
+
+export function auditionStart(id) {
+  return mediaRequest({
+    method: 'get',
+    url: `/streaming/audition_start/${id}`
+  })
+}
+
+export function auditionStop(part_id) {
+  return mediaRequest({
+    method: 'get',
+    url: `/streaming/audition_stop/${part_id}`
   })
 }

+ 49 - 21
src/views/ncs-broadcast/index.vue

@@ -37,6 +37,25 @@
       />
     </ag-grid-layout>
 
+    <el-dialog title="手动播放" width="300" :visible="manulPlay" :show-close="false">
+      <el-row>
+        <el-col :span="24">
+          {{auditionTotalMsg}}
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="24">
+          {{auditionMsg}}
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-progress :show-text="false" :text-inside="true" :stroke-width="30" :percentage="auditionPositionPercent" status="success"></el-progress>
+      </el-row>
+      <span slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="stopBroadcast(currentRow)">停止</el-button>
+      </span>
+    </el-dialog>
+
     <el-dialog title="试听" width="300" :visible="stream!==null" :show-close="false">
       <el-row>
         <el-col :span="24">
@@ -210,7 +229,7 @@ export default {
   components: { ButtonCellRenderList, ListFilter, RadioFilter },
   data() {
     return {
-      rtcServer: "ws://192.168.1.55:8188/janus",
+      rtcServer: "ws://192.168.1.188:8188/janus",
       opaqueId: "streaming-"+randomString(12),
       janus: null,  //实例
       pluginHandle: null,   //插件
@@ -221,6 +240,9 @@ export default {
       auditionMsg: null,
       auditionFinished: false,
 
+      manulPlay: false,
+      currentRow: null,
+
       tableData: [],
       /** 列表参数 */
       params: {
@@ -492,25 +514,31 @@ export default {
       this.deleteStreaming(row.id)
     },
     playBroadcast(row) {
-      // API_BroadcastFiles.getAllFileByBroadcastId(row.id).then(res => {
-      //   if (Array.isArray(res)) {
-      //     this.music = res.map(p => { return { name: p.file_name, url: serverUrl + '/' + p.file_url, artist: p.file_author } })
-      //     console.log(this.music)
-      //   }
-      // })
-      this.websock.send(JSON.stringify({ 'command': 'play', 'broadcast_id': row.id }))
-      // API_Broadcast.playBroadcast(row.id).then(() => {
-      //   row.playing = true
-      //   // this.gridApi.redrawRows()
-      //   this.gridApi.redrawRows()
-      // })
+      API_Broadcast.manulStart(row.id).then(res=>{
+        const result = res.data
+        if (!result.success){
+          this.$message({
+            type: 'error',
+            message: result.message
+          })
+        } else {
+          this.$message({
+            type: 'success',
+            message: '播放成功'
+          })
+          row.playing = true
+          this.gridApi.redrawRows()
+          this.manulPlay = true
+          this.currentRow = row
+        }
+      })
     },
     stopBroadcast(row) {
-      this.websock.send(JSON.stringify({ 'command': 'stop', 'broadcast_id': row.id }))
-      // API_Broadcast.stopBroadcast(row.id).then(() => {
-      //   row.playing = false
-      //   this.gridApi.redrawRows()
-      // })
+      row.playing = false
+      this.gridApi.redrawRows()
+      this.manulPlay = false
+      this.currentRow = null
+      API_Broadcast.manulStop(this.$store.getters.partId, row.id)
     },
     /**
      * 创建广播
@@ -734,7 +762,7 @@ export default {
     },
     initAuditionWebSocket: function() {
       const stockbase = domain.mediaUrl.replace('http', 'ws')
-      this.websock = new WebSocket(stockbase + '/audition/' + this.$store.getters.uuid)
+      this.websock = new WebSocket(stockbase + '/audition/' + this.$store.getters.partId)
       this.websock.onopen = this.websocketonopen
       this.websock.onerror = this.websocketonerror
       this.websock.onmessage = this.websocketonmessage
@@ -962,7 +990,7 @@ export default {
       }})
     },
     streamingStart(id) {
-      API_Broadcast.auditionStart(id, this.$store.getters.uuid).then(res=>{
+      API_Broadcast.auditionStart(id).then(res=>{
         const result = res.data
         if (!result.success){
           this.$message({
@@ -979,7 +1007,7 @@ export default {
       this.pluginHandle.hangup()
       this.onCleanup()
       if (personClose) {
-        API_Broadcast.auditionStop(this.$store.getters.uuid)
+        API_Broadcast.auditionStop(this.$store.getters.partId)
       }
       this.auditionMsg = null
     },