|
@@ -12,6 +12,7 @@
|
|
<el-row type="flex" align="middle">
|
|
<el-row type="flex" align="middle">
|
|
<el-col :span="4" style="padding-left: 10px;"><el-avatar :src="u.avatar"></el-avatar></el-col>
|
|
<el-col :span="4" style="padding-left: 10px;"><el-avatar :src="u.avatar"></el-avatar></el-col>
|
|
<el-col :span="19" :offset="1">{{ u.nickName }}</el-col>
|
|
<el-col :span="19" :offset="1">{{ u.nickName }}</el-col>
|
|
|
|
+ <el-col :span="19" :offset="1">{{ u.userId }}</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="4" >
|
|
<el-col :span="4" >
|
|
@@ -32,6 +33,7 @@
|
|
<el-row type="flex" align="middle">
|
|
<el-row type="flex" align="middle">
|
|
<el-col :span="4" style="padding-left: 10px;"><el-avatar :src="u.avatar"></el-avatar></el-col>
|
|
<el-col :span="4" style="padding-left: 10px;"><el-avatar :src="u.avatar"></el-avatar></el-col>
|
|
<el-col :span="19" :offset="1">{{ u.nickName }}</el-col>
|
|
<el-col :span="19" :offset="1">{{ u.nickName }}</el-col>
|
|
|
|
+ <el-col :span="19" :offset="1">{{ u.userId }}</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="4" >
|
|
<el-col :span="4" >
|
|
@@ -52,6 +54,7 @@
|
|
<el-row type="flex" align="middle">
|
|
<el-row type="flex" align="middle">
|
|
<el-col :span="4" style="padding-left: 10px;"><el-avatar :src="u.avatar"></el-avatar></el-col>
|
|
<el-col :span="4" style="padding-left: 10px;"><el-avatar :src="u.avatar"></el-avatar></el-col>
|
|
<el-col :span="19" :offset="1">{{ u.nickName }}</el-col>
|
|
<el-col :span="19" :offset="1">{{ u.nickName }}</el-col>
|
|
|
|
+ <el-col :span="19" :offset="1">{{ u.userId }}</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="4" >
|
|
<el-col :span="4" >
|
|
@@ -75,40 +78,40 @@
|
|
<div style="border-radius: 5px; overflow: hidden;">
|
|
<div style="border-radius: 5px; overflow: hidden;">
|
|
<video
|
|
<video
|
|
controls
|
|
controls
|
|
|
|
+ ref="videoPlayer"
|
|
autoplay
|
|
autoplay
|
|
- :src="this.liveVideo.videoUrl"
|
|
|
|
width="100%"
|
|
width="100%"
|
|
style="display: block; background: #000;"
|
|
style="display: block; background: #000;"
|
|
></video>
|
|
></video>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 底部导航栏 -->
|
|
<!-- 底部导航栏 -->
|
|
- <div style="display: flex; justify-content: space-around; padding: 15px 0; background: #fff; border-top: 1px solid #f0f0f0;">
|
|
|
|
- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">
|
|
|
|
- <i class="el-icon-microphone" style="font-size: 20px;"></i>
|
|
|
|
- <span style="font-size: 12px; margin-top: 4px;">语音</span>
|
|
|
|
- </div>
|
|
|
|
- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">
|
|
|
|
- <i class="el-icon-video-camera" style="font-size: 20px;"></i>
|
|
|
|
- <span style="font-size: 12px; margin-top: 4px;">视频</span>
|
|
|
|
- </div>
|
|
|
|
- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">
|
|
|
|
- <i class="el-icon-share" style="font-size: 20px;"></i>
|
|
|
|
- <span style="font-size: 12px; margin-top: 4px;">分享</span>
|
|
|
|
- </div>
|
|
|
|
- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">
|
|
|
|
- <i class="el-icon-message" style="font-size: 20px;"></i>
|
|
|
|
- <span style="font-size: 12px; margin-top: 4px;">评论</span>
|
|
|
|
- </div>
|
|
|
|
- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">
|
|
|
|
- <i class="el-icon-goods" style="font-size: 20px;"></i>
|
|
|
|
- <span style="font-size: 12px; margin-top: 4px;">商品</span>
|
|
|
|
- </div>
|
|
|
|
- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">
|
|
|
|
- <i class="el-icon-menu" style="font-size: 20px;"></i>
|
|
|
|
- <span style="font-size: 12px; margin-top: 4px;">工具箱</span>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+<!-- <div style="display: flex; justify-content: space-around; padding: 15px 0; background: #fff; border-top: 1px solid #f0f0f0;">-->
|
|
|
|
+<!-- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">-->
|
|
|
|
+<!-- <i class="el-icon-microphone" style="font-size: 20px;"></i>-->
|
|
|
|
+<!-- <span style="font-size: 12px; margin-top: 4px;">语音</span>-->
|
|
|
|
+<!-- </div>-->
|
|
|
|
+<!-- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">-->
|
|
|
|
+<!-- <i class="el-icon-video-camera" style="font-size: 20px;"></i>-->
|
|
|
|
+<!-- <span style="font-size: 12px; margin-top: 4px;">视频</span>-->
|
|
|
|
+<!-- </div>-->
|
|
|
|
+<!-- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">-->
|
|
|
|
+<!-- <i class="el-icon-share" style="font-size: 20px;"></i>-->
|
|
|
|
+<!-- <span style="font-size: 12px; margin-top: 4px;">分享</span>-->
|
|
|
|
+<!-- </div>-->
|
|
|
|
+<!-- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">-->
|
|
|
|
+<!-- <i class="el-icon-message" style="font-size: 20px;"></i>-->
|
|
|
|
+<!-- <span style="font-size: 12px; margin-top: 4px;">评论</span>-->
|
|
|
|
+<!-- </div>-->
|
|
|
|
+<!-- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">-->
|
|
|
|
+<!-- <i class="el-icon-goods" style="font-size: 20px;"></i>-->
|
|
|
|
+<!-- <span style="font-size: 12px; margin-top: 4px;">商品</span>-->
|
|
|
|
+<!-- </div>-->
|
|
|
|
+<!-- <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;">-->
|
|
|
|
+<!-- <i class="el-icon-menu" style="font-size: 20px;"></i>-->
|
|
|
|
+<!-- <span style="font-size: 12px; margin-top: 4px;">工具箱</span>-->
|
|
|
|
+<!-- </div>-->
|
|
|
|
+<!-- </div>-->
|
|
</el-col>
|
|
</el-col>
|
|
<!-- 直播/视频 end -->
|
|
<!-- 直播/视频 end -->
|
|
|
|
|
|
@@ -176,8 +179,10 @@
|
|
<script>
|
|
<script>
|
|
import { changeUserStatus, watchUserList } from '@/api/live/liveWatchUser'
|
|
import { changeUserStatus, watchUserList } from '@/api/live/liveWatchUser'
|
|
import { getLiveVideoByLiveId } from '@/api/live/liveVideo'
|
|
import { getLiveVideoByLiveId } from '@/api/live/liveVideo'
|
|
|
|
+import { getLivingUrl } from '@/api/live/live'
|
|
import { listLiveMsg } from '@/api/live/liveMsg'
|
|
import { listLiveMsg } from '@/api/live/liveMsg'
|
|
import { LiveWS } from '@/utils/liveWS'
|
|
import { LiveWS } from '@/utils/liveWS'
|
|
|
|
+import flvjs from 'flv.js';
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "LiveConsole",
|
|
name: "LiveConsole",
|
|
@@ -189,6 +194,7 @@ export default {
|
|
tabRight: {
|
|
tabRight: {
|
|
activeName: "talk",
|
|
activeName: "talk",
|
|
},
|
|
},
|
|
|
|
+ livingUrl:"",
|
|
liveVideo: {},
|
|
liveVideo: {},
|
|
socket: null,
|
|
socket: null,
|
|
liveWsUrl: process.env.VUE_APP_LIVE_WS_URL + '/app/webSocket',
|
|
liveWsUrl: process.env.VUE_APP_LIVE_WS_URL + '/app/webSocket',
|
|
@@ -209,8 +215,9 @@ export default {
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
// this.getLiveVideo()
|
|
// this.getLiveVideo()
|
|
- // this.getList()
|
|
|
|
|
|
+ this.getList()
|
|
this.connectWebSocket()
|
|
this.connectWebSocket()
|
|
|
|
+ this.getLiveUrl()
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
liveId() {
|
|
liveId() {
|
|
@@ -251,6 +258,32 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ getLiveUrl(){
|
|
|
|
+ getLivingUrl(this.liveId).then(res=>{
|
|
|
|
+ if(res.code === 200){
|
|
|
|
+ this.livingUrl = res.livingUrl
|
|
|
|
+ this.initPlayer()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ initPlayer(){
|
|
|
|
+ if (flvjs.isSupported()) {
|
|
|
|
+ const videoElement = this.$refs.videoPlayer
|
|
|
|
+ var flvPlayer = flvjs.createPlayer({
|
|
|
|
+ type: 'flv',
|
|
|
|
+ // qfedu 是推流的时候的路径名称
|
|
|
|
+ // dixon 是stream 自定义的名称
|
|
|
|
+ url: this.livingUrl,
|
|
|
|
+ enableWorker: true,
|
|
|
|
+ enableStashBuffer: false, // 禁用内部缓冲区
|
|
|
|
+ stashInitialSize: 128, // 减小初始缓冲大小
|
|
|
|
+ autoCleanupSourceBuffer: true
|
|
|
|
+ });
|
|
|
|
+ flvPlayer.attachMediaElement(videoElement);
|
|
|
|
+ flvPlayer.load();
|
|
|
|
+ flvPlayer.play();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
handleClick(tab) {
|
|
handleClick(tab) {
|
|
console.log("click",tab.name)
|
|
console.log("click",tab.name)
|
|
console.log("liveId", this.liveId)
|
|
console.log("liveId", this.liveId)
|
|
@@ -385,7 +418,6 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
connectWebSocket() {
|
|
connectWebSocket() {
|
|
- console.log(this.liveWsUrl)
|
|
|
|
let socket = new LiveWS(this.liveWsUrl, this.liveId, this.userId);
|
|
let socket = new LiveWS(this.liveWsUrl, this.liveId, this.userId);
|
|
socket.onmessage = (event) => this.handleWsMessage(event)
|
|
socket.onmessage = (event) => this.handleWsMessage(event)
|
|
this.socket = socket
|
|
this.socket = socket
|
|
@@ -414,14 +446,16 @@ export default {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
else if (cmd === 'entry' || cmd === 'out') {
|
|
else if (cmd === 'entry' || cmd === 'out') {
|
|
- let user = JSON.parse(data.data)
|
|
|
|
- this.userList = this.userList.filter(u => u.userId !== user.userId)
|
|
|
|
|
|
+
|
|
|
|
+ let user = data
|
|
|
|
+ if(this.userList.length > 0){
|
|
|
|
+ this.userList = this.userList.filter(u => u.userId !== user.userId)
|
|
|
|
+ }
|
|
this.userList.push(user)
|
|
this.userList.push(user)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
sendMessage() {
|
|
sendMessage() {
|
|
- console.log(this.newMsg);
|
|
|
|
// 发送前简单校验
|
|
// 发送前简单校验
|
|
if (this.newMsg.trim() === '') {
|
|
if (this.newMsg.trim() === '') {
|
|
return;
|
|
return;
|