更换直播流地址

main
刘妍 2 months ago
parent 16b693d266
commit b4427ecc58

@ -16,8 +16,10 @@ export const airPortStore = defineStore({
video_id: '1581F8HGX254V00A0BUY/99-0-0/normal-0',
},
liveInfo: {
rtmp: 'rtmp://175.27.168.120:6019/live/',
url: 'http://175.27.168.120:6012/live/',
// rtmp: 'rtmp://175.27.168.120:6019/live/',
// url: 'http://175.27.168.120:6012/live/',
rtmp: 'rtmp://box.wisestcity.com:1935/live/',
url: 'http://box.wisestcity.com:8081/live/',
},
}),
getters: {

@ -1,6 +1,6 @@
import { getClient, createConnection, clientPublish, clientSubscribe } from '@/utils/mqtt';
import { airPortStore } from '@/store/modules/airport';
import error_code from './error_code.json';
import errorCode from './error_code.json';
const airPortStoreVal = airPortStore();
const airPort = airPortStoreVal.getAirport;
@ -28,6 +28,7 @@ export const cover_opensStatus = {
};
export const errorName = (code) => {
const error_code = errorCode.error_code;
if (error_code[code]) {
return error_code[code];
} else {

@ -41,7 +41,7 @@
import { startLive, endLive } from '@/api/workmanagement/airportMaintenance';
import TCPlayer from 'tcplayer.js';
import 'tcplayer.js/dist/tcplayer.min.css'; //
import { servicesTopic, services_replyTopic ,errorName} from '@/utils/debugging/remote';
import { servicesTopic, services_replyTopic, errorName } from '@/utils/debugging/remote';
import { useMessage } from '@/hooks/web/useMessage';
import { buildGUID } from '@/utils/uuid';
import { airPortStore } from '@/store/modules/airport';
@ -53,7 +53,7 @@
const width = ref(500);
const height = ref(348);
const left = ref(pageWidth - 800);
const top = ref(pageHeight - 500);
const top = ref(pageHeight - 460);
const axisVal = ref('none');
const airPortStoreVal = airPortStore();
const live_info = airPortStoreVal.getLiveInfo;
@ -65,17 +65,19 @@
});
let player;
const liveCode = ref('5');
console.log(liveCode);
watch(
() => props.msgData,
(val) => {
// console.log(val);
},
);
const startTid = buildGUID();
const startLiveFun = () => {
const querys = {
bid: buildGUID(),
method: 'live_start_push',
tid: buildGUID(),
tid: startTid,
timestamp: new Date().getTime(),
data: {
url_type: 1, // 0 = RTMP 1GB28181 3WebRTC 4
@ -89,11 +91,12 @@
servicesTopic(querys);
services_replyTopic();
};
const stopTid = buildGUID();
const closeLive = () => {
const querys = {
bid: buildGUID(),
method: 'live_stop_push',
tid: buildGUID(),
tid: stopTid,
timestamp: new Date().getTime(),
data: {
video_id: airPort.video_id,
@ -120,7 +123,7 @@
});
getClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
if (rs.method == 'live_start_push') {
if (rs.method == 'live_start_push' && rs.tid == startTid) {
if (rs.data.result == 0) {
createMessage.success('开始直播成功');
player.src(live_info.url + liveCode.value + '.flv');
@ -132,7 +135,7 @@
} else {
createMessage.error('开始直播失败,' + errorName(rs.data.result));
}
} else if (rs.method == 'live_stop_push') {
} else if (rs.method == 'live_stop_push' && rs.tid == stopTid) {
if (rs.data.result == 0) {
createMessage.success('停止直播成功');
if (player) {
@ -153,7 +156,6 @@
onBeforeUnmount(() => {
player.dispose();
player = null;
closeLive();
});
</script>
<style lang="less" scoped>

@ -70,7 +70,7 @@
} from '@/api/workmanagement/airportMaintenance';
import TCPlayer from 'tcplayer.js';
import 'tcplayer.js/dist/tcplayer.min.css'; //
import { servicesTopic, services_replyTopic ,errorName} from '@/utils/debugging/remote';
import { servicesTopic, services_replyTopic, errorName } from '@/utils/debugging/remote';
import { useMessage } from '@/hooks/web/useMessage';
import { airPortStore } from '@/store/modules/airport';
import VueDragResize from 'vue-drag-resize/src';
@ -90,15 +90,19 @@
const width = ref(500);
const height = ref(348);
const left = ref(pageWidth - 800);
const top = ref(pageHeight - 500);
const top = ref(pageHeight - 440);
if (props.airportLiveVisible) {
top.value = pageHeight - 100;
top.value = pageHeight - 820;
}
let player;
const liveCode = ref('6');
watch(
() => props.msgData,
(val) => {},
() => props.airportLiveVisible,
(val) => {
if (val) {
top.value = pageHeight - 820;
}
},
);
const cameraType = ref('广角');
@ -144,11 +148,12 @@
},
],
});
const startTid = buildGUID();
const startLiveFun = () => {
const querys = {
bid: buildGUID(),
method: 'live_start_push',
tid: buildGUID(),
tid: startTid,
timestamp: new Date().getTime(),
data: {
url_type: 1, // 0 = RTMP 1GB28181 3WebRTC 4
@ -160,11 +165,12 @@
servicesTopic(querys);
services_replyTopic();
};
const qualityTid = buildGUID();
const resolutionChange = (val: any) => {
const querys = {
bid: buildGUID(),
method: 'live_set_quality',
tid: buildGUID(),
tid: qualityTid,
timestamp: new Date().getTime(),
data: {
video_id: uav.video_id,
@ -173,6 +179,7 @@
};
servicesTopic(querys);
};
const lensTid = buildGUID();
const cameraChange = (val: any) => {
optionsArr.cameraOptions.forEach((item) => {
if (item.value === selectVal.camera) {
@ -183,7 +190,7 @@
const querys = {
bid: buildGUID(),
method: 'live_lens_change',
tid: buildGUID(),
tid: lensTid,
timestamp: new Date().getTime(),
data: {
video_id: uav.video_id,
@ -208,11 +215,12 @@
licenseUrl: live_info.url + liveCode.value + '.flv', // license license licenseUrl
});
};
const stopTid = buildGUID();
const closeLive = () => {
const querys = {
bid: buildGUID(),
method: 'live_stop_push',
tid: buildGUID(),
tid: stopTid,
timestamp: new Date().getTime(),
data: {
video_id: uav.video_id,
@ -231,7 +239,7 @@
playVideo();
getClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
if (rs.method == 'live_start_push') {
if (rs.method == 'live_start_push' && rs.tid == startTid) {
if (rs.data.result == 0) {
createMessage.success('无人机开始直播成功');
player.src(live_info.url + liveCode.value + '.flv');
@ -243,7 +251,7 @@
} else {
createMessage.error('开始直播失败,' + errorName(rs.data.result));
}
} else if (rs.method == 'live_stop_push') {
} else if (rs.method == 'live_stop_push' && rs.tid == stopTid) {
if (rs.data.result == 0) {
createMessage.success('无人机停止直播成功');
if (player) {
@ -252,7 +260,7 @@
} else {
createMessage.error('无人机停止直播失败,' + errorName(rs.data.result));
}
} else if (rs.method == 'live_set_quality') {
} else if (rs.method == 'live_set_quality' && rs.tid == qualityTid) {
if (rs.data.result == 0) {
createMessage.success('无人机设置清晰度成功');
player.src(live_info.url + '4.flv');
@ -260,7 +268,7 @@
} else {
createMessage.error('无人机设置清晰度失败,' + errorName(rs.data.result));
}
} else if (rs.method == 'live_lens_change') {
} else if (rs.method == 'live_lens_change' && rs.tid == lensTid) {
if (rs.data.result == 0) {
createMessage.success('无人机设置直播镜头成功');
player.src(live_info.url + liveCode.value + '.flv');
@ -280,7 +288,6 @@
onBeforeUnmount(() => {
player.dispose();
player = null;
closeLive();
});
</script>
<style lang="less" scoped>

Loading…
Cancel
Save