Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switches for input devices #3447

Merged
merged 5 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions app/page/template/video-calling.htm
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@
data-bind="click: clickedOnStopVideo, css: {'video-controls__button--active': selfStreamState.videoSend()}, attr: {'data-uie-value': selfStreamState.videoSend() ? 'active' : 'inactive'}"
data-uie-name="do-call-controls-toggle-video">
<camera-icon></camera-icon>
<div class="video-controls__button__label" data-bind="l10n_text: z.string.videoCallOverlayVideo"></div>

<!-- ko if: showSwitchCamera() -->
<device-toggle-button data-bind="click: clickedOnToggleCamera"
params="index: currentDeviceIndex.video_input,
devices: availableDevices.video_input,
type: z.media.MediaDeviceType.VIDEO_INPUT">
</device-toggle-button>
<!-- /ko -->
<!-- ko ifnot: showSwitchCamera -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for consistency, can we try to call the showSwitchCamera observable always the same way.
Either showSwitchCamera() or showSwitchCamera.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe showSwitchCamera() would be better, so that we don't, when reading the code, testing that the observable exists with testing the actual value of the observable.

<div class="video-controls__button__label" data-bind="l10n_text: z.string.videoCallOverlayVideo"></div>
<!-- /ko -->
</div>
<!-- /ko -->

Expand All @@ -61,7 +69,16 @@
data-bind="click: clickedOnShareScreen, css: {'video-controls__button--active': selfStreamState.screenSend(), 'video-controls__button--disabled': disableToggleScreen()}"
data-uie-name="do-call-controls-toggle-screen">
<screenshare-icon></screenshare-icon>
<div class="video-controls__button__label" data-bind="l10n_text: z.string.videoCallOverlayShareScreen"></div>
<!-- ko if: showSwitchScreen -->
<device-toggle-button data-bind="click: clickedOnToggleScreen"
params="index: currentDeviceIndex.screen_input,
devices: availableDevices.screen_input,
type: z.media.MediaDeviceType.SCREEN_INPUT">
</device-toggle-button>
<!-- /ko -->
<!-- ko ifnot: showSwitchScreen -->
<div class="video-controls__button__label" data-bind="l10n_text: z.string.videoCallOverlayShareScreen"></div>
<!-- /ko -->
</div>
<!-- /ko -->

Expand Down
3 changes: 0 additions & 3 deletions app/script/components/calling/deviceToggleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ z.components.DeviceToggleButton = class DeviceToggleButton {
constructor(params) {
this.availableDevices = params.devices;
this.currentDeviceIndex = params.index;
this.iconClass = params.type === z.media.MediaDeviceType.VIDEO_INPUT ? 'icon-video' : 'icon-screensharing';

this.numberOfDevices = ko.pureComputed(() => {
return _.isArray(this.availableDevices()) ? this.availableDevices().length : 0;
});
Expand All @@ -36,7 +34,6 @@ z.components.DeviceToggleButton = class DeviceToggleButton {

ko.components.register('device-toggle-button', {
template: `
<div class="device-toggle-button-icon" data-bind="css: iconClass"></div>
<div class="device-toggle-button-indicator">
<!-- ko foreach: ko.utils.range(0, numberOfDevices() - 1) -->
<span class="device-toggle-button-indicator-dot" data-bind="css: {'device-toggle-button-indicator-dot-active': $data == $parent.currentDeviceIndex()}"></span>
Expand Down
11 changes: 11 additions & 0 deletions app/script/view_model/VideoCallingViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ z.viewModel.VideoCallingViewModel = class VideoCallingViewModel {
}
});

this.showSwitchCamera = ko.pureComputed(() => {
const hasMultipleCameras = this.availableDevices.video_input().length > 1;
const isVisible = hasMultipleCameras && this.localVideoStream() && this.selfStreamState.videoSend();
return this.isCallOngoing() && isVisible;
});
this.showSwitchScreen = ko.pureComputed(() => {
const hasMultipleCameras = this.availableDevices.screen_input().length > 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasMultipleCameras => hasMultipleScreens

const isVisible = hasMultipleCameras && this.localVideoStream() && this.selfStreamState.screenSend();
return this.isCallOngoing() && isVisible;
});

this.showControls = ko.pureComputed(() => {
const isFullscreenEnabled = this.showRemoteParticipant() && !this.multitasking.isMinimized();
const isVisible = this.showRemoteVideo() || isFullscreenEnabled;
Expand Down
7 changes: 7 additions & 0 deletions app/style/video-calling.less
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@
white-space: nowrap;
}

device-toggle-button {
position: absolute;
bottom: -16px;
left: 50%;
transform: translateX(-50%);
}

&:hover &__label {
opacity: 1;
}
Expand Down