Switch video rooms to spotlight layout when in PiP mode (#8912)
* Switch video rooms to spotlight layout when in PiP mode * Add some comments
This commit is contained in:
parent
5c67ef14ec
commit
84cf40e0f3
3 changed files with 74 additions and 18 deletions
|
@ -25,6 +25,7 @@ import defaultDispatcher from "../dispatcher/dispatcher";
|
|||
import { ActionPayload } from "../dispatcher/payloads";
|
||||
import { ElementWidgetActions } from "./widgets/ElementWidgetActions";
|
||||
import { WidgetMessagingStore, WidgetMessagingStoreEvent } from "./widgets/WidgetMessagingStore";
|
||||
import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "./ActiveWidgetStore";
|
||||
import { STUCK_DEVICE_TIMEOUT_MS, getVideoChannel, addOurDevice, removeOurDevice } from "../utils/VideoChannelUtils";
|
||||
import { timeout } from "../utils/promise";
|
||||
import WidgetUtils from "../utils/WidgetUtils";
|
||||
|
@ -234,6 +235,8 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
|
|||
}
|
||||
|
||||
this.connected = true;
|
||||
ActiveWidgetStore.instance.on(ActiveWidgetStoreEvent.Dock, this.onDock);
|
||||
ActiveWidgetStore.instance.on(ActiveWidgetStoreEvent.Undock, this.onUndock);
|
||||
this.room.on(RoomEvent.MyMembership, this.onMyMembership);
|
||||
window.addEventListener("beforeunload", this.setDisconnected);
|
||||
|
||||
|
@ -264,8 +267,14 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
|
|||
const roomId = this.roomId;
|
||||
const room = this.room;
|
||||
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants);
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.MuteAudio}`, this.onMuteAudio);
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.UnmuteAudio}`, this.onUnmuteAudio);
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.MuteVideo}`, this.onMuteVideo);
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.UnmuteVideo}`, this.onUnmuteVideo);
|
||||
this.activeChannel.off(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
|
||||
ActiveWidgetStore.instance.off(ActiveWidgetStoreEvent.Dock, this.onDock);
|
||||
ActiveWidgetStore.instance.off(ActiveWidgetStoreEvent.Undock, this.onUndock);
|
||||
room.off(RoomEvent.MyMembership, this.onMyMembership);
|
||||
window.removeEventListener("beforeunload", this.setDisconnected);
|
||||
clearInterval(this.resendDevicesTimer);
|
||||
|
@ -324,4 +333,15 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
|
|||
private onMyMembership = (room: Room, membership: string) => {
|
||||
if (membership !== "join") this.setDisconnected();
|
||||
};
|
||||
|
||||
private onDock = async () => {
|
||||
// The widget is no longer a PiP, so let's restore the default layout
|
||||
await this.activeChannel.transport.send(ElementWidgetActions.TileLayout, {});
|
||||
};
|
||||
|
||||
private onUndock = async () => {
|
||||
// The widget has become a PiP, so let's switch Jitsi to spotlight mode
|
||||
// to only show the active speaker and economize on space
|
||||
await this.activeChannel.transport.send(ElementWidgetActions.SpotlightLayout, {});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import { IWidgetApiRequest } from "matrix-widget-api";
|
|||
export enum ElementWidgetActions {
|
||||
ClientReady = "im.vector.ready",
|
||||
WidgetReady = "io.element.widget_ready",
|
||||
|
||||
// All of these actions are currently specific to Jitsi
|
||||
JoinCall = "io.element.join",
|
||||
HangupCall = "im.vector.hangup",
|
||||
ForceHangupCall = "io.element.force_hangup",
|
||||
|
@ -28,6 +30,10 @@ export enum ElementWidgetActions {
|
|||
MuteVideo = "io.element.mute_video",
|
||||
UnmuteVideo = "io.element.unmute_video",
|
||||
StartLiveStream = "im.vector.start_live_stream",
|
||||
// Actions for switching layouts
|
||||
TileLayout = "io.element.tile_layout",
|
||||
SpotlightLayout = "io.element.spotlight_layout",
|
||||
|
||||
OpenIntegrationManager = "integration_manager_open",
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue