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.
This commit is contained in:
parent
011e44b4f9
commit
1ef813e509
@ -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<ApplicationFeatures>;
|
||||
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<void>();
|
||||
|
||||
// === 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);
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user