-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from mujik-tigers/feat/92-live-playing-video
feat: 라이브 영상 저장 기능 구현
- Loading branch information
Showing
11 changed files
with
133 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/site/youtogether/playlist/PlayingDefaultVideo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package site.youtogether.playlist; | ||
|
||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
|
||
import site.youtogether.exception.playlist.PlaylistEmptyException; | ||
import site.youtogether.message.VideoSyncInfoMessage; | ||
import site.youtogether.message.application.MessageService; | ||
import site.youtogether.playlist.application.PlaylistService; | ||
|
||
public class PlayingDefaultVideo extends PlayingVideo { | ||
|
||
private final long totalTime; | ||
|
||
public PlayingDefaultVideo(String roomCode, Video video, MessageService messageService, PlaylistService playlistService) { | ||
super(roomCode, video, messageService, playlistService); | ||
this.totalTime = video.getDuration(); | ||
} | ||
|
||
@Override | ||
protected void createTimer(double playerRate) { | ||
timer = new Timer(); | ||
timer.scheduleAtFixedRate(new TimerTask() { | ||
@Override | ||
public void run() { | ||
if (currentTime >= totalTime) { | ||
messageService.sendVideoSyncInfo( | ||
new VideoSyncInfoMessage(roomCode, videoId, PlayerState.END, totalTime, playerRate) | ||
); | ||
try { | ||
playlistService.callNextVideoByTimer(roomCode); | ||
} catch (PlaylistEmptyException ignored) { | ||
} | ||
timer.cancel(); | ||
timer.purge(); | ||
return; | ||
} | ||
messageService.sendVideoSyncInfo( | ||
new VideoSyncInfoMessage(roomCode, videoId, PlayerState.PLAY, currentTime, playerRate) | ||
); | ||
currentTime += 1; | ||
} | ||
}, 0, timerPeriod); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/site/youtogether/playlist/PlayingLiveVideo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package site.youtogether.playlist; | ||
|
||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
|
||
import site.youtogether.message.VideoSyncInfoMessage; | ||
import site.youtogether.message.application.MessageService; | ||
import site.youtogether.playlist.application.PlaylistService; | ||
|
||
public class PlayingLiveVideo extends PlayingVideo { | ||
|
||
public PlayingLiveVideo(String roomCode, Video video, MessageService messageService, PlaylistService playlistService) { | ||
super(roomCode, video, messageService, playlistService); | ||
} | ||
|
||
@Override | ||
protected void createTimer(double playerRate) { | ||
timer = new Timer(); | ||
timer.scheduleAtFixedRate(new TimerTask() { | ||
@Override | ||
public void run() { | ||
messageService.sendVideoSyncInfo( | ||
new VideoSyncInfoMessage(roomCode, videoId, PlayerState.PLAY, currentTime, playerRate) | ||
); | ||
currentTime += 1; | ||
} | ||
}, 0, timerPeriod); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,5 @@ for _, key in ipairs(userList) do | |
end | ||
end | ||
|
||
return eraseRoomList | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters