diff --git a/lib/main.dart b/lib/main.dart index 3cff0420a..b2efa98e6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -123,7 +123,9 @@ class MyApp extends StatelessWidget { DisplayMode preferred = modes.toList().firstWhere((el) => el == f); FlutterDisplayMode.setPreferredMode(preferred); }); - } catch (_) {} + } catch (e) { + SmartDialog.showToast('设置帧率失败:$e', displayTime: const Duration(milliseconds: 500)); + } } return DynamicColorBuilder( diff --git a/lib/pages/emote/view.dart b/lib/pages/emote/view.dart index 6ec6e87b1..d08d8d0ad 100644 --- a/lib/pages/emote/view.dart +++ b/lib/pages/emote/view.dart @@ -23,8 +23,8 @@ class _EmotePanelState extends State @override void initState() { - _futureBuilderFuture = _emotePanelController.getEmote(); super.initState(); + _futureBuilderFuture = _emotePanelController.getEmote(); } @override diff --git a/lib/pages/history/view.dart b/lib/pages/history/view.dart index c86e3c46a..f886100a4 100644 --- a/lib/pages/history/view.dart +++ b/lib/pages/history/view.dart @@ -24,8 +24,8 @@ class _HistoryPageState extends State { @override void initState() { - _futureBuilderFuture = _historyController.queryHistoryList(); super.initState(); + _futureBuilderFuture = _historyController.queryHistoryList(); scrollController = _historyController.scrollController; scrollController.addListener( () { diff --git a/lib/pages/rcmd/view.dart b/lib/pages/rcmd/view.dart index 9626df6dc..3babecca3 100644 --- a/lib/pages/rcmd/view.dart +++ b/lib/pages/rcmd/view.dart @@ -94,7 +94,8 @@ class _RcmdPageState extends State sliver: FutureBuilder( future: _futureBuilderFuture, builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.data != null) { Map data = snapshot.data as Map; if (data['status']) { return Obx( @@ -111,7 +112,7 @@ class _RcmdPageState extends State ); } else { return HttpError( - errMsg: data['msg'], + errMsg: data == null ? "" : data['msg'], fn: () { setState(() { _rcmdController.isLoadingMore = true; diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 7fed9a1b0..3c2a6eda7 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -268,7 +268,9 @@ class VideoDetailController extends GetxController // 硬解 enableHA: enableHA.value, seekTo: seekToTime ?? defaultST, - duration: duration ?? Duration(milliseconds: data.timeLength ?? 0), + duration: duration ?? data.timeLength == null + ? null + : Duration(milliseconds: data.timeLength!), // 宽>高 水平 否则 垂直 direction: firstVideo.width != null && firstVideo.height != null ? ((firstVideo.width! - firstVideo.height!) > 0 diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 42c75dec5..c79b4b6a9 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -39,11 +39,11 @@ class _VideoReplyReplyPanelState extends State { @override void initState() { + super.initState(); _videoReplyReplyController = Get.put( VideoReplyReplyController( widget.oid, widget.rpid.toString(), widget.replyType!), tag: widget.rpid.toString()); - super.initState(); // 上拉加载更多 scrollController = _videoReplyReplyController.scrollController; diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 2ef67d702..d87b0de6b 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -293,10 +293,20 @@ class _VideoDetailPageState extends State !videoDetailController.isShowCover.value; videoIntroController.isPaused = false; if (autoplay) { - await Future.delayed(const Duration(milliseconds: 300)); - plPlayerController?.seekTo(videoDetailController.defaultST); - plPlayerController?.play(); + // await Future.delayed(const Duration(milliseconds: 300)); + if (plPlayerController?.buffered.value == Duration.zero) { + plPlayerController?.buffered.listen((p0) { + if (p0 > Duration.zero) { + plPlayerController?.seekTo(videoDetailController.defaultST); + plPlayerController?.play(); + } + }); + } else { + plPlayerController?.seekTo(videoDetailController.defaultST); + plPlayerController?.play(); + } } + AutoOrientation.fullAutoMode(); plPlayerController?.addStatusLister(playerListener); if (plPlayerController != null) { listenFullScreenStatus(); diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index d37af510f..6eec4604b 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1063,19 +1063,16 @@ class _HeaderControlState extends State { size: 15, color: Colors.white, ), - onPressed: () => >{ - if (widget.controller!.isFullScreen.value) - {widget.controller!.triggerFullScreen(status: false)} - else - { - if (MediaQuery.of(context).orientation == - Orientation.landscape && - !horizontalScreen) - { - verticalScreenForTwoSeconds(), - }, - Get.back() - } + onPressed: () { + if (widget.controller!.isFullScreen.value) { + widget.controller!.triggerFullScreen(status: false); + } else if (MediaQuery.of(context).orientation == + Orientation.landscape && + !horizontalScreen) { + verticalScreenForTwoSeconds(); + } else { + Get.back(); + } }, )), if ((videoIntroController.videoDetail.value.title != null) && diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 0b0e2b4a0..b159163a5 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -83,8 +83,8 @@ class PlPlayerController { final Rx _videoFit = Rx(videoFitType.first['attr']); final Rx _videoFitDesc = Rx(videoFitType.first['desc']); - late StreamSubscription _bufferedListenerForVideoFit; - late StreamSubscription _bufferedListenerForEnterFullscreen; + late StreamSubscription _dataListenerForVideoFit; + late StreamSubscription _dataListenerForEnterFullscreen; /// // ignore: prefer_final_fields @@ -233,7 +233,6 @@ class PlPlayerController { late double strokeWidth; late double danmakuDurationVal; late List speedsList; - // 缓存 double? defaultDuration; late bool enableAutoLongPressSpeed = false; @@ -555,10 +554,10 @@ class PlPlayerController { bool autoEnterFullscreen = GStrorage.setting .get(SettingBoxKey.enableAutoEnter, defaultValue: false); if (autoEnterFullscreen) { - if (buffered.value == Duration.zero) { - _bufferedListenerForEnterFullscreen = buffered.listen((status) { - if (status > Duration.zero) { - _bufferedListenerForEnterFullscreen.cancel(); + if (dataStatus.status.value != DataStatus.loaded) { + _dataListenerForEnterFullscreen = dataStatus.status.listen((status) { + if (status == DataStatus.loaded) { + _dataListenerForEnterFullscreen.cancel(); triggerFullScreen(status: true); } }); @@ -930,9 +929,9 @@ class PlPlayerController { if (attr == BoxFit.none || attr == BoxFit.scaleDown) { if (buffered.value == Duration.zero) { attr = BoxFit.contain; - _bufferedListenerForVideoFit = buffered.listen((status) { - if (status > Duration.zero) { - _bufferedListenerForVideoFit.cancel(); + _dataListenerForVideoFit = dataStatus.status.listen((status) { + if (status == DataStatus.loaded) { + _dataListenerForVideoFit.cancel(); int fitValue = videoStorage.get(VideoBoxKey.cacheVideoFit, defaultValue: 0); var attr = videoFitType[fitValue]['attr']; @@ -1023,9 +1022,13 @@ class PlPlayerController { // StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE); showStatusBar(); toggleFullScreen(false); - if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false) && - mode != FullScreenMode.none) { + if (mode == FullScreenMode.none) { + return; + } + if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) { await verticalScreenForTwoSeconds(); + } else { + await autoScreen(); } } }