添加静音图标

This commit is contained in:
fangxiang 2021-12-23 09:28:21 +08:00
parent 5811d2f7f6
commit 7e456340dc
7 changed files with 108 additions and 35 deletions

View File

@ -635,6 +635,26 @@ export default class ClientConnection {
} }
} }
public async unmuteWindow(window_id: number) {
try {
return await this.doRpc<Protocol.NoneResponse>(
new Protocol.UnMuteWindowRequestEntity(window_id, 0)
);
} catch (e) {
console.error(e);
}
}
public async muteWindow(window_id: number) {
try {
return await this.doRpc<Protocol.NoneResponse>(
new Protocol.MuteWindowRequestEntity(window_id, 0)
);
} catch (e) {
console.error(e);
}
}
public restartDevice(delay_ms?: number) { public restartDevice(delay_ms?: number) {
this.ws?.send( this.ws?.send(
JSON.stringify(new Protocol.RestartDeviceRequestEntity(delay_ms)) JSON.stringify(new Protocol.RestartDeviceRequestEntity(delay_ms))

View File

@ -19,7 +19,7 @@
v-close-popup v-close-popup
:disable="$props.disable" :disable="$props.disable"
@click="$emit('edit_volume', $props.window.window_id)" @click="$emit('edit_volume', $props.window.window_id)"
v-if="!$props.window.muted" v-if="!$props.window.muted && is_audo_player_window"
> >
<q-item-section> {{ $t("edit volume") }} </q-item-section> <q-item-section> {{ $t("edit volume") }} </q-item-section>
</q-item> </q-item>
@ -28,8 +28,11 @@
v-close-popup v-close-popup
:disable="$props.disable" :disable="$props.disable"
@click="$emit('mute_unmute', $props.window.window_id)" @click="$emit('mute_unmute', $props.window.window_id)"
v-if="is_audo_player_window"
> >
<q-item-section> {{ $t("mute") }} </q-item-section> <q-item-section>
{{ $props.window.muted ? $t("unmute") : $t("mute") }}
</q-item-section>
</q-item> </q-item>
<q-item <q-item
clickable clickable
@ -59,9 +62,14 @@
</q-item> </q-item>
</q-list> </q-list>
</q-popup-proxy> </q-popup-proxy>
<div class="title_bar full-width"> <div class="row title_bar full-width">
<q-icon :name="getItemIcon(signal_source.window_type)" /> <q-icon :name="getItemIcon(signal_source.window_type)" class="q-mr-xs" />
<span>{{ signal_source.name }}</span> <span>{{ signal_source.name }}</span>
<q-space />
<q-icon
v-if="is_audo_player_window"
:name="$props.window.muted ? 'volume_off' : 'volume_up'"
/>
</div> </div>
<div <div
@ -250,7 +258,7 @@ div.absolute_left_down {
import { Common } from "src/common/Common"; import { Common } from "src/common/Common";
import EventBus, { EventNamesDefine } from "src/common/EventBus"; import EventBus, { EventNamesDefine } from "src/common/EventBus";
import GlobalData from "src/common/GlobalData"; import GlobalData from "src/common/GlobalData";
import { defineComponent, ref, watch, onUnmounted } from "vue"; import { defineComponent, ref, watch, onUnmounted, computed } from "vue";
import { useStore } from "src/store"; import { useStore } from "src/store";
import { SignalSourceEntity } from "src/entities/SignalSourceEntity"; import { SignalSourceEntity } from "src/entities/SignalSourceEntity";
@ -306,8 +314,15 @@ export default defineComponent({
signal_source.value, signal_source.value,
GlobalData.getInstance().getSignalSource(props.signal_source_table_uuid) GlobalData.getInstance().getSignalSource(props.signal_source_table_uuid)
); );
console.log(signal_source.value.window_type);
}; };
const is_audo_player_window = computed(
() =>
signal_source.value.window_type == "EwindowType::Multimedia" ||
signal_source.value.window_type == "EwindowType::HdmiIn"
);
reload_signal_source(); reload_signal_source();
watch(props, (a, b) => { watch(props, (a, b) => {
reload_signal_source(); reload_signal_source();
@ -346,7 +361,7 @@ export default defineComponent({
}); });
watch( watch(
() => props.window.window_state, () => props.window.focus,
(newValue, oldValue) => { (newValue, oldValue) => {
if (newValue) { if (newValue) {
let old = selected.value; let old = selected.value;
@ -379,6 +394,7 @@ export default defineComponent({
can_move, can_move,
can_resize, can_resize,
flags, flags,
is_audo_player_window,
onClick(evt: PointerEvent) { onClick(evt: PointerEvent) {
if (selected.value != true) { if (selected.value != true) {

View File

@ -2,18 +2,6 @@ import BaseEntity from "./BaseEntity";
import { SignalSourceEntity } from "./SignalSourceEntity"; import { SignalSourceEntity } from "./SignalSourceEntity";
import { Protocol } from "./WSProtocol"; import { Protocol } from "./WSProtocol";
export class WindowStates {
playing = false;
focus = false;
muted = false;
constructor(playing?: boolean, focus?: boolean, muted?: boolean) {
this.playing = playing ?? false;
this.focus = focus ?? false;
this.muted = muted ?? false;
}
}
export class MultimediaWindowEntity extends BaseEntity { export class MultimediaWindowEntity extends BaseEntity {
x: number = 0; x: number = 0;
y: number = 0; y: number = 0;
@ -21,7 +9,6 @@ export class MultimediaWindowEntity extends BaseEntity {
height: number = 0; height: number = 0;
signal_source_table_uuid: string = ""; signal_source_table_uuid: string = "";
window_state = new WindowStates();
volume: number = 80; volume: number = 80;
muted: boolean = false; muted: boolean = false;
paused: boolean = false; paused: boolean = false;

View File

@ -224,6 +224,14 @@ export namespace Protocol {
return Commands.PROTOCOL_PREFIX + "SetWindowVolume"; return Commands.PROTOCOL_PREFIX + "SetWindowVolume";
} }
public static get kMuteWidow() {
return Commands.PROTOCOL_PREFIX + "MuteWidow";
}
public static get kUnMuteWidow() {
return Commands.PROTOCOL_PREFIX + "UnMuteWidow";
}
static _all_commands = new Set([ static _all_commands = new Set([
Commands.kUnKnowCommand, Commands.kUnKnowCommand,
Commands.kSearchDevice, Commands.kSearchDevice,
@ -275,6 +283,8 @@ export namespace Protocol {
Commands.kRpcSetOutputBoardSetting, Commands.kRpcSetOutputBoardSetting,
Commands.kRpcGetOutputBoardSetting, Commands.kRpcGetOutputBoardSetting,
Commands.kSetWindowVolume, Commands.kSetWindowVolume,
Commands.kMuteWidow,
Commands.kUnMuteWidow,
]); ]);
public static get AllCommands() { public static get AllCommands() {
@ -1351,4 +1361,26 @@ export namespace Protocol {
this.volume = volume; this.volume = volume;
} }
} }
export class MuteWindowRequestEntity extends Protocol.PacketEntity {
window_id: number;
constructor(window_id: number, rcp_id?: number) {
super();
this.rpc_id = rcp_id ?? 0;
this.command = Protocol.Commands.kMuteWidow;
this.window_id = window_id;
}
}
export class UnMuteWindowRequestEntity extends Protocol.PacketEntity {
window_id: number;
constructor(window_id: number, rcp_id?: number) {
super();
this.rpc_id = rcp_id ?? 0;
this.command = Protocol.Commands.kUnMuteWidow;
this.window_id = window_id;
}
}
} }

View File

@ -5,4 +5,5 @@ export default class WindowOtherStateChangeNotifyEntity extends Protocol.PacketE
playing = false; playing = false;
focus = false; focus = false;
muted = false; muted = false;
volume = 80;
} }

View File

@ -265,6 +265,7 @@ export default {
"重要图形参数已更改,需要重启后生效,是否重启", "重要图形参数已更改,需要重启后生效,是否重启",
"output audio card": "输出声卡", "output audio card": "输出声卡",
muted: "静音", muted: "静音",
unmute: "取消静音",
"the system will reboot after the setup is complete": "the system will reboot after the setup is complete":
"系统将在设置完成后重启", "系统将在设置完成后重启",
"restart command send": "重启指令发送", "restart command send": "重启指令发送",

View File

@ -115,10 +115,7 @@ import Window from "src/components/Window.vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useStore } from "src/store"; import { useStore } from "src/store";
import EventBus, { EventNamesDefine } from "src/common/EventBus"; import EventBus, { EventNamesDefine } from "src/common/EventBus";
import { import { WindowOpenNotifyEntity } from "src/entities/MultimediaWindowEntity";
WindowOpenNotifyEntity,
WindowStates,
} from "src/entities/MultimediaWindowEntity";
import WindowOtherStateChangeNotifyEntity from "src/entities/WindowOtherStateChangeNotifyEntity"; import WindowOtherStateChangeNotifyEntity from "src/entities/WindowOtherStateChangeNotifyEntity";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { NotifyMessage } from "src/common/ClientConnection"; import { NotifyMessage } from "src/common/ClientConnection";
@ -285,16 +282,30 @@ export default defineComponent({
(item) => item.window_id == temp.window_id (item) => item.window_id == temp.window_id
); );
if (window) { if (window) {
window.window_state; // console.log(temp);
$store.commit("setWindowProperty", { console.log(window);
$store.commit("setWindowPropertys", [
{
window, window,
property_name: "window_state", property_name: "playing",
value: new WindowStates( value: temp.playing,
temp.playing, },
temp.focus, {
temp.muted window,
), property_name: "focus",
}); value: temp.focus,
},
{
window,
property_name: "muted",
value: temp.muted,
},
{
window,
property_name: "volume",
value: temp.volume,
},
]);
} }
} }
} }
@ -535,12 +546,17 @@ export default defineComponent({
} }
}, },
mute_unmute(window_id: number) { mute_unmute(window_id: number) {
console.log(windows.value);
const window = windows.value.find( const window = windows.value.find(
(element) => element && element.window_id == window_id (element) => element && element.window_id == window_id
); );
if (window) { if (window) {
if (window.muted) {
GlobalData.getInstance()
.getCurrentClient()
?.unmuteWindow(window_id);
} else {
GlobalData.getInstance().getCurrentClient()?.muteWindow(window_id);
}
} }
}, },
}; };