Skip to content

Commit

Permalink
reload episodes comments when auto play next episode
Browse files Browse the repository at this point in the history
  • Loading branch information
Predidit committed Feb 15, 2025
1 parent 37fb949 commit de32d82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/pages/player/player_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,6 @@ class _PlayerItemState extends State<PlayerItem>
playerController.brightnessSeeking = false;
playerController.volumeSeeking = false;
playerController.canHidePlayerPanel = true;
// Reset danmaku state
infoController.episodeCommentsList.clear();
infoController.episodeInfo.reset();
super.dispose();
}

Expand Down
15 changes: 14 additions & 1 deletion lib/pages/video/video_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class VideoPage extends StatefulWidget {
}

class _VideoPageState extends State<VideoPage>
with SingleTickerProviderStateMixin, WindowListener {
with TickerProviderStateMixin, WindowListener {
Box setting = GStorage.setting;
final InfoController infoController = Modular.get<InfoController>();
final VideoPageController videoPageController =
Expand All @@ -50,6 +50,7 @@ class _VideoPageState extends State<VideoPage>
late GridObserverController observerController;
late AnimationController animation;
late Animation<Offset> _rightOffsetAnimation;
late TabController tabController;

// 当前播放列表
late int currentRoad;
Expand All @@ -73,6 +74,7 @@ class _VideoPageState extends State<VideoPage>
windowManager.addListener(this);
// Check fullscreen when enter video page
// in case user use system controls to enter fullscreen outside video page
tabController = TabController(length: 2, vsync: this);
videoPageController.isDesktopFullscreen();
observerController = GridObserverController(controller: scrollController);
animation = AnimationController(
Expand Down Expand Up @@ -155,6 +157,7 @@ class _VideoPageState extends State<VideoPage>
ScreenBrightnessPlatform.instance.resetApplicationScreenBrightness();
} catch (_) {}
}
infoController.episodeInfo.reset();
infoController.episodeCommentsList.clear();
Utils.unlockScreenRotation();
super.dispose();
Expand Down Expand Up @@ -200,6 +203,14 @@ class _VideoPageState extends State<VideoPage>
clearLogs();
hideDebugConsole();
videoPageController.loading = true;
infoController.episodeInfo.reset();
infoController.episodeCommentsList.clear();
// Query comments when tab is visible
// We need lazy load comments to avoid unnecessary API requests
// so we only query comments when the tab is visible rather than video is loaded
if (tabController.index == 1) {
infoController.queryBangumiEpisodeCommentsByID(infoController.bangumiItem.id, episode);
}
await playerController.stop();
await videoPageController.changeEpisode(episode,
currentRoad: currentRoad, offset: offset);
Expand Down Expand Up @@ -800,6 +811,7 @@ class _VideoPageState extends State<VideoPage>
Row(
children: [
TabBar(
controller: tabController,
dividerHeight: 0,
isScrollable: true,
tabAlignment: TabAlignment.start,
Expand Down Expand Up @@ -873,6 +885,7 @@ class _VideoPageState extends State<VideoPage>
Divider(height: Utils.isDesktop() ? 0.5 : 0.2),
Expanded(
child: TabBarView(
controller: tabController,
children: [
GridViewObserver(
controller: observerController,
Expand Down

0 comments on commit de32d82

Please sign in to comment.