From 1ef813e50951ea9c1a00925b8dbcf22fcacba354 Mon Sep 17 00:00:00 2001 From: CSantosM <4a.santos@gmail.com> Date: Wed, 21 Jan 2026 17:30:30 +0100 Subject: [PATCH] frontend: Moves sound effects to dedicated service Refactors sound effect logic into a dedicated `SoundService`. This change centralizes audio playback functionality, promoting better code organization and reusability. Removes sound effect logic from the meeting service. --- .../pages/meeting/meeting.component.ts | 16 +++----- .../meeting/services/meeting.service.ts | 8 ---- .../src/lib/shared/services/sound.service.ts | 37 +++++++++++++++++++ 3 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/sound.service.ts diff --git a/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/pages/meeting/meeting.component.ts b/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/pages/meeting/meeting.component.ts index 05c657bd..8bcf2118 100644 --- a/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/pages/meeting/meeting.component.ts +++ b/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/pages/meeting/meeting.component.ts @@ -5,18 +5,17 @@ import { MatIconModule } from '@angular/material/icon'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { OpenViduComponentsUiModule, - OpenViduService, OpenViduThemeMode, OpenViduThemeService, Room, - Track, - ViewportService + Track } from 'openvidu-components-angular'; import { Subject } from 'rxjs'; import { ApplicationFeatures } from '../../../../shared/models/app.model'; import { FeatureConfigurationService } from '../../../../shared/services/feature-configuration.service'; import { GlobalConfigService } from '../../../../shared/services/global-config.service'; import { NotificationService } from '../../../../shared/services/notification.service'; +import { SoundService } from '../../../../shared/services/sound.service'; import { RoomMemberService } from '../../../rooms/services/room-member.service'; import { MeetingLobbyComponent } from '../../components/meeting-lobby/meeting-lobby.component'; import { MeetingParticipantItemComponent } from '../../customization/meeting-participant-item/meeting-participant-item.component'; @@ -24,8 +23,6 @@ import { MeetingCaptionsService } from '../../services/meeting-captions.service' import { MeetingContextService } from '../../services/meeting-context.service'; import { MeetingEventHandlerService } from '../../services/meeting-event-handler.service'; import { MeetingLobbyService } from '../../services/meeting-lobby.service'; -import { MeetingWebComponentManagerService } from '../../services/meeting-webcomponent-manager.service'; -import { MeetingService } from '../../services/meeting.service'; @Component({ selector: 'ov-meeting', @@ -40,7 +37,7 @@ import { MeetingService } from '../../services/meeting.service'; MatProgressSpinnerModule, MeetingLobbyComponent ], - providers: [MeetingLobbyService, MeetingEventHandlerService] + providers: [MeetingLobbyService, MeetingEventHandlerService, SoundService] }) export class MeetingComponent implements OnInit { protected _participantItem?: MeetingParticipantItemComponent; @@ -65,12 +62,8 @@ export class MeetingComponent implements OnInit { protected isMeetingLeft = signal(false); protected features: Signal; - protected meetingService = inject(MeetingService); protected participantService = inject(RoomMemberService); protected featureConfService = inject(FeatureConfigurationService); - protected wcManagerService = inject(MeetingWebComponentManagerService); - protected openviduService = inject(OpenViduService); - protected viewportService = inject(ViewportService); protected ovThemeService = inject(OpenViduThemeService); protected configService = inject(GlobalConfigService); protected notificationService = inject(NotificationService); @@ -78,6 +71,7 @@ export class MeetingComponent implements OnInit { protected meetingContextService = inject(MeetingContextService); protected eventHandlerService = inject(MeetingEventHandlerService); protected captionsService = inject(MeetingCaptionsService); + protected soundService = inject(SoundService); protected destroy$ = new Subject(); // === LOBBY PHASE COMPUTED SIGNALS (when showLobby = true) === @@ -216,7 +210,7 @@ export class MeetingComponent implements OnInit { onParticipantConnected(event: any): void { // Play joined sound - this.meetingService.playParticipantJoinedSound(); + this.soundService.playParticipantJoinedSound(); this.eventHandlerService.onParticipantConnected(event); } diff --git a/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/services/meeting.service.ts b/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/services/meeting.service.ts index d1d36449..6426266c 100644 --- a/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/services/meeting.service.ts +++ b/meet-ce/frontend/projects/shared-meet-components/src/lib/domains/meeting/services/meeting.service.ts @@ -27,14 +27,6 @@ export class MeetingService { this.notificationService.showSnackbar('Speaker link copied to clipboard'); } - /** - * Plays a sound to indicate that a participant has joined the meeting. - */ - playParticipantJoinedSound(): void { - const audio = new Audio('/assets/sounds/participant-joined.mp3'); - audio.volume = 0.5; - audio.play(); - } /** * Ends a meeting by its room ID. diff --git a/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/sound.service.ts b/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/sound.service.ts new file mode 100644 index 00000000..b926b163 --- /dev/null +++ b/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/sound.service.ts @@ -0,0 +1,37 @@ +import { Injectable } from '@angular/core'; + +/** + * Service responsible for managing sound effects within the application. + */ +@Injectable() +export class SoundService { + constructor() {} + + /** + * Plays a sound to indicate that a participant has joined the meeting. + */ + playParticipantJoinedSound(): void { + const audio = new Audio('/assets/sounds/participant-joined.mp3'); + audio.volume = 0.4; + audio.play(); + } + + /** + * Plays a sound to indicate that a participant's role has been upgraded. + */ + playParticipantRoleUpgradedSound(): void { + const audio = new Audio('/assets/sounds/role-upgraded.wav'); + audio.volume = 0.4; + audio.play(); + } + + + /** + * Plays a sound to indicate that a participant's role has been downgraded. + */ + playParticipantRoleDowngradedSound(): void { + const audio = new Audio('/assets/sounds/role-downgraded.wav'); + audio.volume = 0.4; + audio.play(); + } +}