Skip to content

Commit

Permalink
Refactor video player component to include progress bar and update vi…
Browse files Browse the repository at this point in the history
…deo player service
  • Loading branch information
OchiengPaul442 committed Apr 19, 2024
1 parent d2237d7 commit 564fb7a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export class VideoPlayerComponent implements OnDestroy {

private pauseTime = 0;

totalTime: number;

playbackPercentage: number;

constructor(
Expand Down Expand Up @@ -99,16 +101,16 @@ export class VideoPlayerComponent implements OnDestroy {
private async saveVideoState() {
// Getting the total time of the video
const totalTimeResult = await this.videoPlayer.getDuration({ playerId: this.playerId });
const totalTime = totalTimeResult.value;
this.totalTime = totalTimeResult.value || this.totalTime;

// Calculating the playback percentage
this.playbackPercentage = (this.pauseTime / totalTime) * 100;
this.playbackPercentage = (this.pauseTime / this.totalTime) * 100;

// Saving the video state
const videoState = {
videoId: this.playerId,
currentTime: this.pauseTime || 0,
totalTime: totalTime || 0,
totalTime: this.totalTime || 0,
playbackPercentage: this.playbackPercentage || 0,
};
await this.playerService.updateVideoState(videoState);
Expand Down

0 comments on commit 564fb7a

Please sign in to comment.