播放按钮添加loading, 修复拉流代理播放后再次点播失败

master
lin 2025-03-12 16:43:47 +08:00
parent e473ab185d
commit 90d2843255
5 changed files with 32 additions and 83 deletions

View File

@ -186,6 +186,7 @@ public class MediaInfo {
mediaInfo.setOriginType(param.getOriginType()); mediaInfo.setOriginType(param.getOriginType());
mediaInfo.setOriginTypeStr(param.getOriginTypeStr()); mediaInfo.setOriginTypeStr(param.getOriginTypeStr());
mediaInfo.setOriginUrl(param.getOriginUrl()); mediaInfo.setOriginUrl(param.getOriginUrl());
mediaInfo.setOriginUrl(param.getOriginUrl());
mediaInfo.setAliveSecond(param.getAliveSecond()); mediaInfo.setAliveSecond(param.getAliveSecond());
mediaInfo.setBytesSpeed(param.getBytesSpeed()); mediaInfo.setBytesSpeed(param.getBytesSpeed());
mediaInfo.setParamMap(param.getParamMap()); mediaInfo.setParamMap(param.getParamMap());

View File

@ -463,7 +463,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
} }
MediaInfo mediaInfo = getMediaInfo(mediaServer, streamProxy.getApp(), streamProxy.getStream()); MediaInfo mediaInfo = getMediaInfo(mediaServer, streamProxy.getApp(), streamProxy.getStream());
if (mediaInfo != null) { if (mediaInfo != null) {
if (mediaInfo.getOriginUrl().equals(streamProxy.getSrcUrl())) { if (mediaInfo.getOriginUrl() != null && mediaInfo.getOriginUrl().equals(streamProxy.getSrcUrl())) {
log.info("[启动拉流代理] 已存在, 直接返回, app {}, stream: {}", mediaInfo.getApp(), streamProxy.getStream()); log.info("[启动拉流代理] 已存在, 直接返回, app {}, stream: {}", mediaInfo.getApp(), streamProxy.getStream());
return getStreamInfoByAppAndStream(mediaServer, streamProxy.getApp(), streamProxy.getStream(), null, null, true); return getStreamInfoByAppAndStream(mediaServer, streamProxy.getApp(), streamProxy.getStream(), null, null, true);
} }

View File

@ -76,7 +76,7 @@
<el-table-column prop="createTime" label="创建时间" min-width="150" show-overflow-tooltip/> <el-table-column prop="createTime" label="创建时间" min-width="150" show-overflow-tooltip/>
<el-table-column label="操作" width="400" fixed="right"> <el-table-column label="操作" width="400" fixed="right">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-button size="medium" icon="el-icon-video-play" type="text" @click="play(scope.row)"></el-button> <el-button size="medium" :loading="scope.row.playLoading" icon="el-icon-video-play" type="text" @click="play(scope.row)"></el-button>
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
<el-button size="medium" icon="el-icon-switch-button" style="color: #f56c6c" type="text" v-if="scope.row.pulling" @click="stopPlay(scope.row)"></el-button> <el-button size="medium" icon="el-icon-switch-button" style="color: #f56c6c" type="text" v-if="scope.row.pulling" @click="stopPlay(scope.row)"></el-button>
<el-divider direction="vertical" v-if="scope.row.pulling" ></el-divider> <el-divider direction="vertical" v-if="scope.row.pulling" ></el-divider>
@ -134,7 +134,6 @@
currentPage:1, currentPage:1,
count:15, count:15,
total:0, total:0,
startBtnLoading: false,
streamProxy: null, streamProxy: null,
searchSrt: "", searchSrt: "",
mediaServerId: "", mediaServerId: "",
@ -163,9 +162,6 @@
this.mediaServerList = data.data; this.mediaServerList = data.data;
}) })
}, },
stopUpdateList: function (){
window.clearInterval(this.updateLooper)
},
startUpdateList: function (){ startUpdateList: function (){
this.updateLooper = setInterval(()=>{ this.updateLooper = setInterval(()=>{
if (!this.streamProxy) { if (!this.streamProxy) {
@ -198,7 +194,7 @@
if (res.data.code === 0) { if (res.data.code === 0) {
that.total = res.data.data.total; that.total = res.data.data.total;
for (let i = 0; i < res.data.data.list.length; i++) { for (let i = 0; i < res.data.data.list.length; i++) {
res.data.data.list[i]["startBtnLoading"] = false; res.data.data.list[i]["playLoading"] = false;
} }
that.streamProxyList = res.data.data.list; that.streamProxyList = res.data.data.list;
} }
@ -267,21 +263,21 @@
this.streamProxy = null this.streamProxy = null
}, },
play: function(row){ play: function(row){
let that = this; row.playLoading = true;
this.$axios({ this.$axios({
method: 'get', method: 'get',
url:`/api/proxy/start`, url:`/api/proxy/start`,
params: { params: {
id: row.id, id: row.id,
} }
}).then(function (res) { }).then((res)=> {
if (res.data.code === 0) { if (res.data.code === 0) {
that.$refs.devicePlayer.openDialog("streamPlay", null, null, { this.$refs.devicePlayer.openDialog("streamPlay", null, null, {
streamInfo: res.data.data, streamInfo: res.data.data,
hasAudio: true hasAudio: true
}); });
}else { }else {
that.$message({ this.$message({
showClose: true, showClose: true,
message: "获取地址失败:" + res.data.msg, message: "获取地址失败:" + res.data.msg,
type: "error", type: "error",
@ -290,7 +286,9 @@
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); }).finally(()=>{
row.playLoading = false;
})
}, },
stopPlay: function(row){ stopPlay: function(row){
@ -341,54 +339,6 @@
}).catch(() => { }).catch(() => {
}); });
}, },
start: function(row){
this.stopUpdateList()
this.$set(row, 'startBtnLoading', true)
this.$axios({
method: 'get',
url:`/api/proxy/start`,
params: {
app: row.app,
stream: row.stream
}
}).then((res)=> {
if (res.data.code === 0){
this.initData()
}else {
this.$message({
showClose: true,
message: "启动失败,请检查地址是否可用!",
type: "error",
});
}
this.$set(row, 'startBtnLoading', false)
this.startUpdateList()
}).catch((error)=> {
console.log(error);
this.$message({
showClose: true,
message: "启动失败,请检查地址是否可用!",
type: "error",
});
this.$set(row, 'startBtnLoading', false)
this.startUpdateList()
});
},
stop: function(row){
let that = this;
this.$axios({
method: 'get',
url:`/api/proxy/stop`,
params: {
app: row.app,
stream: row.stream
}
}).then(function (res) {
that.initData()
}).catch(function (error) {
console.log(error);
});
},
refresh: function (){ refresh: function (){
this.initData(); this.initData();
} }

View File

@ -78,7 +78,7 @@
<el-table-column label="操作" min-width="360" fixed="right"> <el-table-column label="操作" min-width="360" fixed="right">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-button size="medium" icon="el-icon-video-play"@click="playPush(scope.row)" type="text">播放 <el-button size="medium" :loading="scope.row.playLoading" icon="el-icon-video-play" @click="playPush(scope.row)" type="text">播放
</el-button> </el-button>
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
<el-button size="medium" icon="el-icon-delete" type="text" @click="deletePush(scope.row.id)" style="color: #f56c6c" >删除</el-button> <el-button size="medium" icon="el-icon-delete" type="text" @click="deletePush(scope.row.id)" style="color: #f56c6c" >删除</el-button>
@ -194,6 +194,7 @@ export default {
that.pushList = res.data.data.list; that.pushList = res.data.data.list;
that.pushList.forEach(e => { that.pushList.forEach(e => {
that.$set(e, "location", ""); that.$set(e, "location", "");
that.$set(e, "playLoading", false);
if (e.gbLongitude && e.gbLatitude) { if (e.gbLongitude && e.gbLatitude) {
that.$set(e, "location", e.gbLongitude + "," + e.gbLatitude); that.$set(e, "location", e.gbLongitude + "," + e.gbLatitude);
} }
@ -208,29 +209,28 @@ export default {
}, },
playPush: function (row) { playPush: function (row) {
let that = this; row.playLoading = true;
this.getListLoading = true;
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: '/api/push/start', url: '/api/push/start',
params: { params: {
id: row.id id: row.id
} }
}).then(function (res) { }).then((res) =>{
that.getListLoading = false;
if (res.data.code === 0 ) { if (res.data.code === 0 ) {
that.$refs.devicePlayer.openDialog("streamPlay", null, null, { this.$refs.devicePlayer.openDialog("streamPlay", null, null, {
streamInfo: res.data.data, streamInfo: res.data.data,
hasAudio: true hasAudio: true
}); });
}else { }else {
that.$message.error(res.data.msg); this.$message.error(res.data.msg);
} }
}).catch(function (error) { }).catch(function (error) {
console.error(error); console.error(error);
that.getListLoading = false; }).finally(()=>{
}); row.playLoading = false;
})
}, },
deletePush: function (id) { deletePush: function (id) {
this.$confirm(`确定删除通道?`, '提示', { this.$confirm(`确定删除通道?`, '提示', {

View File

@ -108,7 +108,7 @@
<el-table-column label="操作" min-width="340" fixed="right"> <el-table-column label="操作" min-width="340" fixed="right">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-button size="medium" v-bind:disabled="device == null || device.online === 0" icon="el-icon-video-play" <el-button size="medium" v-bind:disabled="device == null || device.online === 0" icon="el-icon-video-play"
type="text" @click="sendDevicePush(scope.row)">播放 type="text" :loading="scope.row.playLoading" @click="sendDevicePush(scope.row)">播放
</el-button> </el-button>
<el-button size="medium" v-bind:disabled="device == null || device.online === 0" <el-button size="medium" v-bind:disabled="device == null || device.online === 0"
icon="el-icon-switch-button" icon="el-icon-switch-button"
@ -201,7 +201,6 @@ export default {
count: 15, count: 15,
total: 0, total: 0,
beforeUrl: "/deviceList", beforeUrl: "/deviceList",
isLoging: false,
showTree: false, showTree: false,
editId: null, editId: null,
loadSnap: {}, loadSnap: {},
@ -277,6 +276,7 @@ export default {
that.deviceChannelList = res.data.data.list; that.deviceChannelList = res.data.data.list;
that.deviceChannelList.forEach(e => { that.deviceChannelList.forEach(e => {
e.ptzType = e.ptzType + ""; e.ptzType = e.ptzType + "";
that.$set(e, "playLoading", false);
}); });
// //
that.$nextTick(() => { that.$nextTick(() => {
@ -292,44 +292,42 @@ export default {
// //
sendDevicePush: function (itemData) { sendDevicePush: function (itemData) {
let deviceId = this.deviceId; let deviceId = this.deviceId;
this.isLoging = true;
let channelId = itemData.deviceId; let channelId = itemData.deviceId;
itemData.playLoading = true;
console.log("通知设备推流1" + deviceId + " : " + channelId); console.log("通知设备推流1" + deviceId + " : " + channelId);
let that = this;
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: '/api/play/start/' + deviceId + '/' + channelId, url: '/api/play/start/' + deviceId + '/' + channelId,
params: { params: {
isSubStream: this.isSubStream isSubStream: this.isSubStream
} }
}).then(function (res) { }).then((res) =>{
console.log(res) console.log(res)
that.isLoging = false;
if (res.data.code === 0) { if (res.data.code === 0) {
setTimeout(() => { setTimeout(() => {
let snapId = deviceId + "_" + channelId; let snapId = deviceId + "_" + channelId;
that.loadSnap[deviceId + channelId] = 0; this.loadSnap[deviceId + channelId] = 0;
that.getSnapErrorEvent(snapId) this.getSnapErrorEvent(snapId)
}, 5000) }, 5000)
itemData.streamId = res.data.data.stream; itemData.streamId = res.data.data.stream;
that.$refs.devicePlayer.openDialog("media", deviceId, channelId, { this.$refs.devicePlayer.openDialog("media", deviceId, channelId, {
streamInfo: res.data.data, streamInfo: res.data.data,
hasAudio: itemData.hasAudio hasAudio: itemData.hasAudio
}); });
setTimeout(() => { setTimeout(() => {
that.initData(); this.initData();
}, 1000) }, 1000)
} else { } else {
that.$message.error(res.data.msg); this.$message.error(res.data.msg);
} }
}).catch(function (e) { }).catch(function (e) {
console.error(e) console.error(e)
that.isLoging = false;
// that.$message.error(""); // that.$message.error("");
}); }).finally(()=>{
itemData.playLoading = false;
})
}, },
moreClick: function (command, itemData) { moreClick: function (command, itemData) {
if (command === "records") { if (command === "records") {