From 8bcf2de9389fd4735a45c2ed6aa9b14213c5df20 Mon Sep 17 00:00:00 2001 From: Predidit <34627277+Predidit@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:26:05 +0800 Subject: [PATCH] try fix iOS audioSessionCategor --- lib/pages/player/player_item.dart | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart index ee3a0275..ba49f004 100644 --- a/lib/pages/player/player_item.dart +++ b/lib/pages/player/player_item.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:kazumi/utils/logger.dart'; import 'package:kazumi/utils/remote.dart'; import 'package:kazumi/utils/utils.dart'; @@ -226,7 +227,8 @@ class _PlayerItemState extends State playerController.volume = value ?? 0.0; }); // 历史记录相关 - if (playerController.mediaPlayer.value.isPlaying && !videoPageController.loading) { + if (playerController.mediaPlayer.value.isPlaying && + !videoPageController.loading) { historyController.updateHistory( videoPageController.currentEspisode, videoPageController.currentRoad, @@ -529,6 +531,11 @@ class _PlayerItemState extends State @override void initState() { super.initState(); + // workaround for #214 + if (Platform.isIOS) { + FlutterVolumeController.setIOSAudioSessionCategory( + category: AudioSessionCategory.playback); + } WidgetsBinding.instance.addObserver(this); _animationController = AnimationController( duration: const Duration(milliseconds: 300), @@ -987,9 +994,7 @@ class _PlayerItemState extends State right: 0, height: videoPageController.androidFullscreen ? MediaQuery.sizeOf(context).height - : (MediaQuery.sizeOf(context).width * - 9 / - 16), + : (MediaQuery.sizeOf(context).width * 9 / 16), child: DanmakuScreen( key: _danmuKey, createdController: (DanmakuController e) {