Skip to content

Commit

Permalink
Fix: auto set all status
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Oct 8, 2023
1 parent 600c3f1 commit e47bb3f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/views/Cinema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ const updateMsgList = (msg: string) => {
msgList.value.push(msg);
};
const setAllStatus = (playing: boolean, seek: number, rate: number) => {
const setAllStatus = (status: MovieStatus) => {
// playing必须比seek后设置,因为watch的顺序会变成先seek后playing,seek会导致playing状态不正确,导致playing无法设置
room.currentMovieStatus.playing = playing;
setStatus(seek, rate);
room.currentMovieStatus.playing = status.playing;
setStatus(status.seek, status.rate);
};
const setStatus = (seek: number, rate: number) => {
Expand Down Expand Up @@ -503,13 +503,21 @@ watch(
// 播放
case WsMessageType.PLAY: {
setAllStatus(true, jsonData.seek, jsonData.rate);
setAllStatus({
playing: true,
seek: jsonData.seek,
rate: jsonData.rate
});
break;
}
// 暂停
case WsMessageType.PAUSE: {
setAllStatus(false, jsonData.seek, jsonData.rate);
setAllStatus({
playing: false,
seek: jsonData.seek,
rate: jsonData.rate
});
break;
}
Expand All @@ -527,7 +535,7 @@ watch(
// 设置正在播放的影片
case WsMessageType.CURRENT_MOVIE: {
room.currentMovie = jsonData.current.movie;
room.currentMovieStatus = jsonData.current.status;
setAllStatus(jsonData.current.status);
break;
}
Expand Down

0 comments on commit e47bb3f

Please sign in to comment.