diff --git a/projects/player/src/app/components/player-state.component.ts b/projects/player/src/app/components/player-state.component.ts index 0addbe8ade0cf9fabc626806c114835e6fe3324a..ead4b4837d055b47cd6a426c5c462aaefc09ae94 100644 --- a/projects/player/src/app/components/player-state.component.ts +++ b/projects/player/src/app/components/player-state.component.ts @@ -8,7 +8,7 @@ import { UnitPage } from '../../../../common/unit'; import { VeronaSubscriptionService } from '../services/verona-subscription.service'; import { PlayerState, - RunningState, VopContinueCommand, VopPageNavigationCommand, VopStopCommand + RunningState, VopContinueCommand, VopGetStateRequest, VopPageNavigationCommand, VopStopCommand } from '../models/verona'; import { VeronaPostService } from '../services/verona-post.service'; @@ -59,6 +59,9 @@ export class PlayerStateComponent implements OnInit, OnDestroy { this.veronaSubscriptionService.vopStopCommand .pipe(takeUntil(this.ngUnsubscribe)) .subscribe((message: VopStopCommand): void => this.onStop(message)); + this.veronaSubscriptionService.vopGetStateRequest + .pipe(takeUntil(this.ngUnsubscribe)) + .subscribe((message: VopGetStateRequest): void => this.onGetStateRequest(message)); } onSelectedIndexChange(): void { @@ -79,6 +82,15 @@ export class PlayerStateComponent implements OnInit, OnDestroy { this.sendVopStateChangedNotification(); } + private onGetStateRequest(message: VopGetStateRequest): void { + // eslint-disable-next-line no-console + console.log('player: onGetStateRequest', message); + if (message.stop) { + this.running = false; + } + this.sendVopStateChangedNotification(); + } + private onPageNavigation(message: VopPageNavigationCommand): void { // eslint-disable-next-line no-console console.log('player: onPageNavigation', message); diff --git a/projects/player/src/app/services/verona-subscription.service.ts b/projects/player/src/app/services/verona-subscription.service.ts index aba6c4478197b078680a1af13ed0ed6d138cee0b..ff0da49249aeccb8ef8dd38cacfbc2b3fc126f5c 100644 --- a/projects/player/src/app/services/verona-subscription.service.ts +++ b/projects/player/src/app/services/verona-subscription.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { fromEvent, Observable, Subject } from 'rxjs'; import { - VopContinueCommand, + VopContinueCommand, VopGetStateRequest, VopMessage, VopNavigationDeniedNotification, VopPageNavigationCommand, @@ -18,6 +18,7 @@ export class VeronaSubscriptionService { private _vopPageNavigationCommand = new Subject<VopPageNavigationCommand>(); private _vopStopCommand = new Subject<VopStopCommand>(); private _vopContinueCommand = new Subject<VopContinueCommand>(); + private _vopGetStateRequest = new Subject<VopGetStateRequest>(); constructor() { fromEvent(window, 'message') @@ -39,7 +40,6 @@ export class VeronaSubscriptionService { console.log('player: _vopNavigationDeniedNotification ', messageData); this._vopNavigationDeniedNotification.next(messageData); break; - // TODO case 'vopPageNavigationCommand': // eslint-disable-next-line no-console console.log('player: _vopPageNavigationCommand ', messageData); @@ -56,6 +56,10 @@ export class VeronaSubscriptionService { this._vopContinueCommand.next(messageData); break; case 'vopGetStateRequest': + // eslint-disable-next-line no-console + console.log('player: _vopGetStateRequest ', messageData); + this._vopGetStateRequest.next(messageData); + break; default: // eslint-disable-next-line no-console console.warn(`player: got message of unknown type ${messageData.type}`); @@ -81,4 +85,8 @@ export class VeronaSubscriptionService { get vopContinueCommand(): Observable<VopContinueCommand> { return this._vopContinueCommand.asObservable(); } + + get vopGetStateRequest(): Observable<VopGetStateRequest> { + return this._vopGetStateRequest.asObservable(); + } }