From ed452df5669ef55257ff7f60b27648fd86b8f1cf Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Tue, 7 May 2024 12:35:29 -0700 Subject: [PATCH] Fix again --- demos/browser/app/meetingV2/meetingV2.ts | 3 ++- .../app/meetingV2/video/PaginationManager.ts | 14 ++++++----- .../meetingV2/video/VideoTileCollection.ts | 24 ++++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/demos/browser/app/meetingV2/meetingV2.ts b/demos/browser/app/meetingV2/meetingV2.ts index 36cc0f036..dc68d28ec 100644 --- a/demos/browser/app/meetingV2/meetingV2.ts +++ b/demos/browser/app/meetingV2/meetingV2.ts @@ -1907,7 +1907,8 @@ export class DemoMeetingApp this.videoTileCollection = new VideoTileCollection(this.audioVideo, this.meetingLogger, new RemoteVideoManager(this.meetingLogger, this.usePriorityBasedDownlinkPolicy ? this.priorityBasedDownlinkPolicy : this.allHighestDownlinkPolicy), - paginationPageSize) + paginationPageSize, + this.meetingSession.configuration.credentials.attendeeId) this.audioVideo.addObserver(this.videoTileCollection); this.contentShare = new ContentShareManager(this.meetingLogger, this.audioVideo, this.usingStereoMusicAudioProfile); diff --git a/demos/browser/app/meetingV2/video/PaginationManager.ts b/demos/browser/app/meetingV2/video/PaginationManager.ts index adfc8fea5..f31a1b785 100644 --- a/demos/browser/app/meetingV2/video/PaginationManager.ts +++ b/demos/browser/app/meetingV2/video/PaginationManager.ts @@ -5,7 +5,7 @@ export default class PaginationManager { private currentPageStart: number = 0; private all = new Array(); - + constructor(private pageSize: number) {} currentPage(): Array { @@ -21,7 +21,7 @@ export default class PaginationManager { remove(toRemove: Type) { if (this.all.includes(toRemove)) { - this.all.splice(this.all.indexOf(toRemove)); + this.all.splice(this.all.indexOf(toRemove), 1); } } @@ -30,7 +30,7 @@ export default class PaginationManager { if (index === -1) { return; } - this.all.splice(index,1); + this.all.splice(index, 1); } hasNextPage(): boolean { @@ -38,7 +38,7 @@ export default class PaginationManager { } nextPage(): void { - if (!this.hasNextPage) { + if (!this.hasNextPage()) { return; } this.currentPageStart += this.pageSize; @@ -49,6 +49,8 @@ export default class PaginationManager { } previousPage(): void { - this.currentPageStart -= this.pageSize; + if (this.hasPreviousPage()) { + this.currentPageStart -= this.pageSize; + } } -} \ No newline at end of file +} diff --git a/demos/browser/app/meetingV2/video/VideoTileCollection.ts b/demos/browser/app/meetingV2/video/VideoTileCollection.ts index dddcab544..2f8ffc841 100644 --- a/demos/browser/app/meetingV2/video/VideoTileCollection.ts +++ b/demos/browser/app/meetingV2/video/VideoTileCollection.ts @@ -130,7 +130,8 @@ export default class VideoTileCollection implements AudioVideoObserver { constructor(private videoTileController: VideoTileControllerFacade, private logger: Logger, private remoteVideoManager: RemoteVideoManager, - private pageSize: number) { + private pageSize: number, + private localAttendeeId: string) { this.setupVideoTiles(); if (!this.remoteVideoManager.supportsRemoteVideoPreferences()) { @@ -162,7 +163,7 @@ export default class VideoTileCollection implements AudioVideoObserver { } videoTileDidUpdate(tileState: VideoTileState): void { - console.log(`video tile updated: ${JSON.stringify(tileState, null, ' ')}`); + this.logger.info(`video tile updated: ${JSON.stringify(tileState, null, ' ')}`); if (!tileState.boundAttendeeId) { return; } @@ -209,22 +210,20 @@ export default class VideoTileCollection implements AudioVideoObserver { } demoVideoTile.attendeeId = tileState.boundAttendeeId; + // We need to add local video or content to pagination from tile updates + const shouldUpdatePagination = tileState.localTile || (tileState.isContent && tileState.boundAttendeeId.startsWith(this.localAttendeeId)); if (tileState.boundVideoStream) { - demoVideoTile.show(tileState.isContent); - - if (tileState.localTile) { + if (shouldUpdatePagination) { this.pagination.add(tileState.boundAttendeeId); - this.updatePaginatedVisibleTiles(); } } else { // Hide non-active tiles that aren't just paused demoVideoTile.hide(); - - if (tileState.localTile) { + if (shouldUpdatePagination) { this.pagination.remove(tileState.boundAttendeeId); - this.updatePaginatedVisibleTiles(); } } + this.updatePaginatedVisibleTiles(); this.updateLayout(); this.layoutFeaturedTile(); } @@ -374,6 +373,9 @@ export default class VideoTileCollection implements AudioVideoObserver { for (const tile of this.videoTileController.getAllVideoTiles()) { const state = tile.state(); if (state.isContent) { + if (state.boundAttendeeId.startsWith(this.localAttendeeId) && !this.pagination.currentPage().includes(state.boundAttendeeId)) { + return null; + } return state.tileId; } } @@ -452,10 +454,10 @@ export default class VideoTileCollection implements AudioVideoObserver { // We need to manually control visibility of paused tiles anyways so we just do // everything here, even though the preference manager adding/removing will // result in tile callbacks as well. - for (let [index, videoTile] of this.tileIndexToDemoVideoTile.entries()) { + for (let videoTile of this.tileIndexToDemoVideoTile.values()) { if (attendeesToShow.includes(videoTile.attendeeId)) { videoTile.show(false); - } else if (this.tileIndexToTileId[index] !== this.findContentTileId()) { // Always show content + } else { videoTile.hide(); } }