|
@@ -84,9 +84,9 @@ export default {
|
|
|
contrlState: false,
|
|
contrlState: false,
|
|
|
audioState: false,
|
|
audioState: false,
|
|
|
mutedState: true,
|
|
mutedState: true,
|
|
|
|
|
+ warnAudio: false,// 鸣笛
|
|
|
speed: 1, //1低速档 | 2 高速档
|
|
speed: 1, //1低速档 | 2 高速档
|
|
|
muted: true,// 是否静音
|
|
muted: true,// 是否静音
|
|
|
- audioPlay:false,
|
|
|
|
|
signalValue: 0,
|
|
signalValue: 0,
|
|
|
SpeedValue: 0,
|
|
SpeedValue: 0,
|
|
|
iceServers: [
|
|
iceServers: [
|
|
@@ -99,8 +99,7 @@ export default {
|
|
|
credential: "123456",
|
|
credential: "123456",
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
- num: 0,
|
|
|
|
|
- num2:0
|
|
|
|
|
|
|
+ num: 0
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -136,6 +135,7 @@ export default {
|
|
|
console.log("track", evt);
|
|
console.log("track", evt);
|
|
|
this.remoteVideo = document.getElementById("v2");
|
|
this.remoteVideo = document.getElementById("v2");
|
|
|
this.remoteVideo.srcObject = evt.streams[0];
|
|
this.remoteVideo.srcObject = evt.streams[0];
|
|
|
|
|
+ if (evt.track.kind === 'audio') this.remoteAudioTrak = evt.streams[0]
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// listen changestate
|
|
// listen changestate
|
|
@@ -179,7 +179,7 @@ export default {
|
|
|
console.log("电量", data);
|
|
console.log("电量", data);
|
|
|
} else if (data.type === "signal") {
|
|
} else if (data.type === "signal") {
|
|
|
const v = data.data <= 20 ? Math.floor(data.data / 4) : 5
|
|
const v = data.data <= 20 ? Math.floor(data.data / 4) : 5
|
|
|
- this.signalValue = v
|
|
|
|
|
|
|
+ this.signalValue = v || 1
|
|
|
} else if (data.type === 'speed') {
|
|
} else if (data.type === 'speed') {
|
|
|
const v = Math.floor(data.data)
|
|
const v = Math.floor(data.data)
|
|
|
this.SpeedValue = v
|
|
this.SpeedValue = v
|
|
@@ -203,11 +203,11 @@ export default {
|
|
|
if (db.buttons[0].touched) this.speed = 1;
|
|
if (db.buttons[0].touched) this.speed = 1;
|
|
|
// 语音按键R2
|
|
// 语音按键R2
|
|
|
this.audioState = db.buttons[7].touched
|
|
this.audioState = db.buttons[7].touched
|
|
|
- // 静音L2
|
|
|
|
|
- this.mutedState = db.buttons[6].touched
|
|
|
|
|
- // 播放警笛X3
|
|
|
|
|
-
|
|
|
|
|
- console.log(db.buttons);
|
|
|
|
|
|
|
+ // 静音X3
|
|
|
|
|
+ this.mutedState = db.buttons[3].touched
|
|
|
|
|
+ // 播放警笛Y2
|
|
|
|
|
+ this.warnAudio = db.buttons[2].touched
|
|
|
|
|
+ // console.log(db.buttons);
|
|
|
const params = {
|
|
const params = {
|
|
|
v0: Math.floor(db.axes[0] * 128 + 128),
|
|
v0: Math.floor(db.axes[0] * 128 + 128),
|
|
|
v1: Math.floor(db.axes[1] * 128 + 128),
|
|
v1: Math.floor(db.axes[1] * 128 + 128),
|
|
@@ -215,9 +215,7 @@ export default {
|
|
|
v3: this.Gear(this.speed, Math.floor(db.axes[3] * 128 + 128)),
|
|
v3: this.Gear(this.speed, Math.floor(db.axes[3] * 128 + 128)),
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- if (this.socket.connected) {
|
|
|
|
|
- this.socket.emit("msg", { type: "conctrl", conctrl: params });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (this.socket && this.socket.connected) this.socket.emit("msg", { type: "conctrl", conctrl: params });
|
|
|
requestAnimationFrame(this.ControlData);
|
|
requestAnimationFrame(this.ControlData);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -230,20 +228,17 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 鸣笛
|
|
|
|
|
- playWarningAudio(){
|
|
|
|
|
-
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
// 挡位
|
|
// 挡位
|
|
|
Gear(speed, num) {
|
|
Gear(speed, num) {
|
|
|
// 低速档
|
|
// 低速档
|
|
|
if (speed === 1) {
|
|
if (speed === 1) {
|
|
|
if (num < 116) {
|
|
if (num < 116) {
|
|
|
- num = 116;
|
|
|
|
|
|
|
+ // 前
|
|
|
|
|
+ num = 120;
|
|
|
} else if (num >= 120 && num <= 131) {
|
|
} else if (num >= 120 && num <= 131) {
|
|
|
num = 128;
|
|
num = 128;
|
|
|
} else if (num > 140) {
|
|
} else if (num > 140) {
|
|
|
|
|
+ // 后
|
|
|
num = 140;
|
|
num = 140;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -282,6 +277,8 @@ export default {
|
|
|
this.showLoading = false;
|
|
this.showLoading = false;
|
|
|
this.error = err || "";
|
|
this.error = err || "";
|
|
|
this.socket = null;
|
|
this.socket = null;
|
|
|
|
|
+ this.Peer = null
|
|
|
|
|
+ this.num = 0
|
|
|
cancelAnimationFrame(this.ControlData);
|
|
cancelAnimationFrame(this.ControlData);
|
|
|
window.removeEventListener("gamepadconnected", this.conControl);
|
|
window.removeEventListener("gamepadconnected", this.conControl);
|
|
|
window.removeEventListener("gamepaddisconnected", this.disControl);
|
|
window.removeEventListener("gamepaddisconnected", this.disControl);
|
|
@@ -305,11 +302,16 @@ export default {
|
|
|
watch: {
|
|
watch: {
|
|
|
// 静音
|
|
// 静音
|
|
|
mutedState(v) {
|
|
mutedState(v) {
|
|
|
- if (v) this.num++
|
|
|
|
|
- if (!this.remoteVideo) return
|
|
|
|
|
- const state = this.num % 2 ? false : true
|
|
|
|
|
- this.remoteVideo.muted = state
|
|
|
|
|
- this.muted = state
|
|
|
|
|
|
|
+ if (v) {
|
|
|
|
|
+ this.num++
|
|
|
|
|
+ const state = this.num % 2 ? false : true
|
|
|
|
|
+ this.muted = state
|
|
|
|
|
+ if (this.socket && this.socket.connected) this.socket.emit("msg", { type: "contrlAudio", contrlAudio: state });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 鸣笛
|
|
|
|
|
+ warnAudio(v) {
|
|
|
|
|
+ if (v && this.socket && this.socket.connected) this.socket.emit("msg", { type: "warnAudio", warnAudio: v });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|