Skip to content

Commit

Permalink
fix: 일시정지 중에 재생속도를 변경하면 영상이 재생되는 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonise committed Jun 14, 2024
1 parent 7305795 commit 097aa83
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/site/youtogether/playlist/PlayingVideo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@Getter
public abstract class PlayingVideo {

protected PlayerState playerState;
protected final String roomCode;
protected final String videoId;
protected final Long videoNumber;
Expand Down Expand Up @@ -41,24 +42,29 @@ public void startAt(double time) {
timer.cancel();
timer.purge();
currentTime = Math.round(time * 100) / 100.0;
playerState = PlayerState.PLAY;

createTimer(playerRate);
}

public void pauseAt(double time) {
timer.cancel();
timer.purge();
currentTime = Math.round(time * 100) / 100.0;
playerState = PlayerState.PAUSE;

messageService.sendVideoSyncInfo(
new VideoSyncInfoMessage(roomCode, videoNumber, videoId, PlayerState.PAUSE, currentTime, playerRate)
new VideoSyncInfoMessage(roomCode, videoNumber, videoId, playerState, currentTime, playerRate)
);
}

public void stop() {
timer.cancel();
timer.purge();
playerState = PlayerState.END;

messageService.sendVideoSyncInfo(
new VideoSyncInfoMessage(roomCode, videoNumber, videoId, PlayerState.END, currentTime, playerRate)
new VideoSyncInfoMessage(roomCode, videoNumber, videoId, playerState, currentTime, playerRate)
);
}

Expand All @@ -71,7 +77,14 @@ public void changeRate(double playerRate) {

this.playerRate = playerRate;
this.timerPeriod = Math.round(1000 / playerRate);
createTimer(playerRate);

if (playerState == PlayerState.PLAY) {
createTimer(playerRate);
} else if (playerState == PlayerState.PAUSE) {
messageService.sendVideoSyncInfo(
new VideoSyncInfoMessage(roomCode, videoNumber, videoId, playerState, currentTime, playerRate)
);
}
}

protected abstract void createTimer(double playerRate);
Expand Down

0 comments on commit 097aa83

Please sign in to comment.