Skip to content

Commit

Permalink
fix: test trial for local track
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed May 20, 2024
1 parent 5f55e17 commit 54cc3ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,6 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
} else {
this.nativeTrack.enabled = this.enabledStateBeforeBackground;
this.replaceSenderTrack(this.nativeTrack);
if (this.nativeTrack.enabled) {
this.videoHandler.updateSinks();
}
}
this.eventBus.localVideoEnabled.publish({ enabled: this.nativeTrack.enabled, track: this });
};
Expand Down
20 changes: 7 additions & 13 deletions packages/hms-video-store/src/media/tracks/VideoElementManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class VideoElementManager {
for (const videoElement of this.videoElements) {
if (this.track.enabled) {
this.track.addSink(videoElement, requestLayer);
this.resumeVideoPlayback({ target: videoElement } as unknown as Event);
} else {
this.track.removeSink(videoElement, requestLayer);
}
Expand Down Expand Up @@ -84,20 +85,13 @@ export class VideoElementManager {
}

private resumeVideoPlayback = (e: Event) => {
console.trace('Resuming playback');
if (!document.hidden && isMobile()) {
const element = e.target as HTMLVideoElement;
if (!document.hidden && isMobile() && element.paused) {
setTimeout(() => {
const element = e.target as HTMLVideoElement;
if (element.paused) {
element.oncanplaythrough = () => {
console.log('element can play', this.track.peerId);
};
console.log('element paused, try resuming', this.track.peerId);
this.track.addSink(element);
element.play().catch(err => {
HMSLogger.w(this.TAG, `Error resuming video playback for ${this.track.peerId} ${(err as Error).message}`);
});
}
this.track.addSink(element);
element.play().catch(err => {
HMSLogger.w(this.TAG, `Error resuming video playback for ${this.track.peerId} ${(err as Error).message}`);
});
}, 0);
}
};
Expand Down

0 comments on commit 54cc3ca

Please sign in to comment.