diff --git a/libs/ui/playback/src/lib/web-player-view/web-player-view.component.shared-controls.spec.ts b/libs/ui/playback/src/lib/web-player-view/web-player-view.component.shared-controls.spec.ts index 327ea3504..437983321 100644 --- a/libs/ui/playback/src/lib/web-player-view/web-player-view.component.shared-controls.spec.ts +++ b/libs/ui/playback/src/lib/web-player-view/web-player-view.component.shared-controls.spec.ts @@ -1,5 +1,5 @@ import { ClipboardModule } from '@angular/cdk/clipboard'; -import { Component, input, output } from '@angular/core'; +import { Component, input, output, signal } from '@angular/core'; import { ComponentFixture, DeferBlockBehavior, @@ -16,8 +16,9 @@ import { type ResolvedPortalPlayback, VideoPlayer, } from '@iptvnator/shared/interfaces'; -import { RuntimeCapabilitiesService } from '@iptvnator/services'; +import { RuntimeCapabilitiesService, SettingsStore } from '@iptvnator/services'; import type { WebPlayerViewComponent as WebPlayerViewComponentInstance } from './web-player-view.component'; +import { WEB_PLAYER_SHARED_CONTROLS } from '../player-controls'; import { type PlaybackDiagnostic, PlaybackDiagnosticCode, @@ -89,6 +90,8 @@ class StubEmbeddedMpvPlayerComponent { readonly nextEpisodeRequested = output(); } +const webPlayerSharedControls = signal(false); + describe('WebPlayerViewComponent shared web controls metadata', () => { let WebPlayerViewComponent: typeof import('./web-player-view.component').WebPlayerViewComponent; let fixture: ComponentFixture; @@ -100,6 +103,8 @@ describe('WebPlayerViewComponent shared web controls metadata', () => { }); beforeEach(async () => { + webPlayerSharedControls.set(false); + await TestBed.configureTestingModule({ deferBlockBehavior: DeferBlockBehavior.Playthrough, imports: [WebPlayerViewComponent, TranslateModule.forRoot()], @@ -114,6 +119,10 @@ describe('WebPlayerViewComponent shared web controls metadata', () => { provide: RuntimeCapabilitiesService, useValue: { supportsManagedExternalPlayers: false }, }, + { + provide: SettingsStore, + useValue: { webPlayerSharedControls }, + }, ], }) .overrideComponent(WebPlayerViewComponent, { @@ -146,6 +155,34 @@ describe('WebPlayerViewComponent shared web controls metadata', () => { fixture.destroy(); }); + it('snapshots the shared controls setting for each player host', () => { + webPlayerSharedControls.set(true); + fixture.detectChanges(); + + expect( + fixture.debugElement.injector.get(WEB_PLAYER_SHARED_CONTROLS) + ).toBe(true); + + webPlayerSharedControls.set(false); + + expect( + fixture.debugElement.injector.get(WEB_PLAYER_SHARED_CONTROLS) + ).toBe(true); + + fixture.destroy(); + fixture = TestBed.createComponent(WebPlayerViewComponent); + component = fixture.componentInstance; + fixture.componentRef.setInput( + 'streamUrl', + 'https://example.com/next.ts' + ); + fixture.detectChanges(); + + expect( + fixture.debugElement.injector.get(WEB_PLAYER_SHARED_CONTROLS) + ).toBe(false); + }); + it.each([ ['an explicit VOD value', { isLive: false }, false], [ diff --git a/libs/ui/playback/src/lib/web-player-view/web-player-view.component.ts b/libs/ui/playback/src/lib/web-player-view/web-player-view.component.ts index ca3804065..fbab90b9e 100644 --- a/libs/ui/playback/src/lib/web-player-view/web-player-view.component.ts +++ b/libs/ui/playback/src/lib/web-player-view/web-player-view.component.ts @@ -25,10 +25,14 @@ import { VideoPlayer, } from '@iptvnator/shared/interfaces'; import type { ExternalPlayerName } from '@iptvnator/shared/interfaces'; -import { RuntimeCapabilitiesService } from '@iptvnator/services'; +import { RuntimeCapabilitiesService, SettingsStore } from '@iptvnator/services'; import { ArtPlayerComponent } from '../art-player/art-player.component'; import { EmbeddedMpvPlayerComponent } from '../embedded-mpv-player/embedded-mpv-player.component'; import { HtmlVideoPlayerComponent } from '../html-video-player/html-video-player.component'; +import { + WEB_PLAYER_SHARED_CONTROLS, + WEB_PLAYER_SHARED_CONTROLS_ENABLED, +} from '../player-controls'; import { type PlaybackDiagnostic, PlaybackDiagnosticCode, @@ -44,6 +48,13 @@ type PlaybackDiagnosticDetail = { readonly value: string; }; +function resolveWebPlayerSharedControls(): boolean { + const storedValue = inject(SettingsStore).webPlayerSharedControls?.(); + return typeof storedValue === 'boolean' + ? storedValue + : WEB_PLAYER_SHARED_CONTROLS_ENABLED; +} + @Component({ selector: 'app-web-player-view', templateUrl: './web-player-view.component.html', @@ -62,6 +73,12 @@ type PlaybackDiagnosticDetail = { TranslatePipe, VjsPlayerComponent, ], + providers: [ + { + provide: WEB_PLAYER_SHARED_CONTROLS, + useFactory: resolveWebPlayerSharedControls, + }, + ], encapsulation: ViewEncapsulation.None, }) export class WebPlayerViewComponent {