Skip to content

Commit

Permalink
Merge pull request #259 from richard-austin/stage-6-mouse-wheel-contr…
Browse files Browse the repository at this point in the history
…olled-zoom-on-live-video

* Full screen and audio toggle buttons added to recording page.
  • Loading branch information
richard-austin committed Feb 4, 2024
2 parents ba2b20a + 9b05a97 commit d79463c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 31 deletions.
12 changes: 12 additions & 0 deletions client/src/app/recording-control/recording-control.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@
<div>
<app-video></app-video>
<div class="buttons-flex-container">
<div class="additional-buttons">
<label *ngIf="hasAudio()" class="video-buttons"
[matTooltip]="'Click to ' + (isMuted() ? 'unmute' : 'mute') + ' sound'"
matTooltipClass="tooltip">
<mat-icon (click)="toggleMuteAudio()">{{ isMuted() ? 'volume_off' : 'volume_up' }}</mat-icon>
</label>
<label class="video-buttons"
matTooltip="Set full screen"
matTooltipClass="tooltip">
<mat-icon (click)="video.setFullScreen()">fullscreen</mat-icon>
</label>
</div>
<mat-card class="recording-buttons hide-background mat-elevation-z8">
<mat-button-toggle-group aria-label="Playback control" name="playbackControl"
[(ngModel)]="selectedPlaybackMode">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ mat-card.recording-buttons {
}
}

div.additional-buttons {
margin-top: 0.3rem;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
}

div.no-display {
display: none;
}
Expand Down
21 changes: 21 additions & 0 deletions client/src/app/recording-control/recording-control.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ export class RecordingControlComponent implements OnInit, AfterViewInit, OnDestr
this.showInvalidInput(false);
}
}
hasAudio (): boolean {
const video: any = this.video?.video;
if(video) {
return video.mozHasAudio ||
Boolean(video.webkitAudioDecodedByteCount) ||
Boolean(video.audioTracks && video.audioTracks.length);
}
return false;
}

/**
* showInvalidInput: Called after checking for a valid recording for this component.
Expand Down Expand Up @@ -361,4 +370,16 @@ export class RecordingControlComponent implements OnInit, AfterViewInit, OnDestr
ngOnDestroy(): void {
this.video.video.controls = true; // Enable controls again
}

toggleMuteAudio() {
if(this.video !== undefined && this.video !== null)
this.video.videoFeeder.mute(!this.video.videoFeeder.isMuted);
}

isMuted() : boolean {
let retVal = false;
if(this.video !== undefined && this.video !== null)
retVal = this.video.videoFeeder.isMuted;
return retVal;
}
}
27 changes: 0 additions & 27 deletions client/src/app/video/video.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,6 @@ div.latency-limit-selector {
}
}

.video-buttons {
cursor: pointer;
@media only screen and (max-width: 768px){
:active {
scale: 1.3;
transition: scale 350ms linear
}
:not(:active) {
scale: 1;
transition-property: transform;
transition: scale 350ms linear;
}
}
@media only screen and (min-width: 768px) {
:hover {
scale: 1.3;
transition: scale 350ms
}

:not(:hover) {
scale: 1;
transition-property: transform;
transition: scale 350ms linear;
}
}
}

.audio-out-disabled {
color: gray !important;
cursor: pointer;
Expand Down
8 changes: 5 additions & 3 deletions client/src/app/video/video.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
this.video.addEventListener('fullscreenchange', () => {
this.vt.reset(); // Set to normal scale for if the mouse wheel was turned while full screen showing
});
this.video.ontimeupdate = (ev:Event) => {
this.currentTime = new Date( this.video.currentTime * 1000).toISOString().substring(11, 19);
this.totalTime = new Date( this.video.duration * 1000).toISOString().substring(11, 19);
this.video.ontimeupdate = () => {
if (this.video.currentTime !== null && !isNaN(this.video.currentTime))
this.currentTime = new Date(this.video.currentTime * 1000).toISOString().substring(11, 19);
if (this.video.duration !== null && !isNaN(this.video.duration))
this.totalTime = new Date(this.video.duration * 1000).toISOString().substring(11, 19);
};
window.screen.orientation.onchange = (ev: Event) => {
// Set up VideoTransformations again to take account of viewport dimension changes
Expand Down
28 changes: 27 additions & 1 deletion client/src/styles.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '~@angular/material' as mat;
@use '@angular/material' as mat;
@include mat.core;

// Basic colours used in theme
Expand Down Expand Up @@ -185,4 +185,30 @@ mat-card.hide-background {
margin-left: 0.5rem;
}
}
label.video-buttons {
cursor: pointer;
@media only screen and (max-width: 768px){
:active {
scale: 1.3;
transition: scale 350ms linear
}
:not(:active) {
scale: 1;
transition-property: transform;
transition: scale 350ms linear;
}
}
@media only screen and (min-width: 768px) {
:hover {
scale: 1.3;
transition: scale 350ms
}

:not(:hover) {
scale: 1;
transition-property: transform;
transition: scale 350ms linear;
}
}
}

0 comments on commit d79463c

Please sign in to comment.