fix: 屏幕阅读器点击按钮无声

This commit is contained in:
orz12
2024-08-25 23:52:10 +08:00
parent a7bfd4b156
commit d2b8c01ac4
4 changed files with 31 additions and 39 deletions

View File

@@ -102,9 +102,7 @@ class _BottomControlState extends State<BottomControl> {
canUsePiP = false; canUsePiP = false;
} }
if (canUsePiP) { if (canUsePiP) {
await widget.floating!.enable( await widget.floating!.enable(const EnableManual());
const EnableManual()
);
} else {} } else {}
}, },
icon: const Icon( icon: const Icon(
@@ -117,9 +115,9 @@ class _BottomControlState extends State<BottomControl> {
const SizedBox(width: 4), const SizedBox(width: 4),
], ],
ComBtn( ComBtn(
tooltip: '全屏切换',
icon: const Icon( icon: const Icon(
Icons.fullscreen, Icons.fullscreen,
semanticLabel: '全屏切换',
size: 20, size: 20,
color: Colors.white, color: Colors.white,
), ),

View File

@@ -231,6 +231,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: ComBtn( child: ComBtn(
icon: const Icon( icon: const Icon(
Icons.skip_previous, Icons.skip_previous,
semanticLabel: '上一集',
size: 22, size: 22,
color: Colors.white, color: Colors.white,
), ),
@@ -246,7 +247,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
SmartDialog.showToast('已经是第一集了'); SmartDialog.showToast('已经是第一集了');
} }
}, },
tooltip: '上一集',
), ),
), ),
@@ -263,6 +263,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: ComBtn( child: ComBtn(
icon: const Icon( icon: const Icon(
Icons.skip_next, Icons.skip_next,
semanticLabel: '下一集',
size: 22, size: 22,
color: Colors.white, color: Colors.white,
), ),
@@ -278,7 +279,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
SmartDialog.showToast('已经是最后一集了'); SmartDialog.showToast('已经是最后一集了');
} }
}, },
tooltip: '下一集',
), ),
), ),
@@ -327,10 +327,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: ComBtn( child: ComBtn(
icon: const Icon( icon: const Icon(
Icons.list, Icons.list,
semanticLabel: '选集',
size: 22, size: 22,
color: Colors.white, color: Colors.white,
), ),
tooltip: '选集',
fuc: () { fuc: () {
int currentCid = widget.controller.cid; int currentCid = widget.controller.cid;
String bvid = widget.controller.bvid; String bvid = widget.controller.bvid;
@@ -466,9 +466,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
width: 42, width: 42,
height: 30, height: 30,
child: Obx(() => ComBtn( child: Obx(() => ComBtn(
tooltip: _.isFullScreen.value ? '退出全屏' : '全屏',
icon: Icon( icon: Icon(
_.isFullScreen.value ? Icons.fullscreen_exit : Icons.fullscreen, _.isFullScreen.value ? Icons.fullscreen_exit : Icons.fullscreen,
semanticLabel: _.isFullScreen.value ? '退出全屏' : '全屏',
size: 24, size: 24,
color: Colors.white, color: Colors.white,
), ),
@@ -607,10 +607,12 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
void fullScreenTrigger(bool status) { void fullScreenTrigger(bool status) {
EasyThrottle.throttle( EasyThrottle.throttle(
'fullScreen', const Duration(milliseconds: 800), () async { 'fullScreen', const Duration(milliseconds: 800),
() async {
await _.triggerFullScreen(status: status); await _.triggerFullScreen(status: status);
}); });
} }
if (cumulativeDy > threshold) { if (cumulativeDy > threshold) {
_gestureType = 'center_down'; _gestureType = 'center_down';
if (_.isFullScreen.value ^ fullScreenGestureReverse) { if (_.isFullScreen.value ^ fullScreenGestureReverse) {
@@ -1052,11 +1054,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
visible: _.showControls.value && visible: _.showControls.value &&
(_.isFullScreen.value || _.controlsLock.value), (_.isFullScreen.value || _.controlsLock.value),
child: ComBtn( child: ComBtn(
tooltip: _.controlsLock.value ? '解锁' : '锁定',
icon: Icon( icon: Icon(
_.controlsLock.value _.controlsLock.value
? FontAwesomeIcons.lock ? FontAwesomeIcons.lock
: FontAwesomeIcons.lockOpen, : FontAwesomeIcons.lockOpen,
semanticLabel: _.controlsLock.value ? '解锁' : '锁定',
size: 15, size: 15,
color: Colors.white, color: Colors.white,
), ),
@@ -1077,9 +1079,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: Visibility( child: Visibility(
visible: _.showControls.value && _.isFullScreen.value, visible: _.showControls.value && _.isFullScreen.value,
child: ComBtn( child: ComBtn(
tooltip: '截图',
icon: const Icon( icon: const Icon(
Icons.photo_camera, Icons.photo_camera,
semanticLabel: '截图',
size: 20, size: 20,
color: Colors.white, color: Colors.white,
), ),
@@ -1224,7 +1226,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
Duration.zero, Duration.zero,
player.state.duration, player.state.duration,
); );
player.seek(result); widget.controller.seekTo(result, type: 'slider');
widget.controller.play(); widget.controller.play();
}, },
), ),
@@ -1269,7 +1271,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
Duration.zero, Duration.zero,
player.state.duration, player.state.duration,
); );
player.seek(result); widget.controller.seekTo(result, type: 'slider');
widget.controller.play(); widget.controller.play();
}, },
), ),

View File

@@ -3,12 +3,10 @@ import 'package:flutter/material.dart';
class ComBtn extends StatelessWidget { class ComBtn extends StatelessWidget {
final Widget? icon; final Widget? icon;
final Function? fuc; final Function? fuc;
final String tooltip;
const ComBtn({ const ComBtn({
this.icon, this.icon,
this.fuc, this.fuc,
required this.tooltip,
super.key, super.key,
}); });
@@ -17,15 +15,11 @@ class ComBtn extends StatelessWidget {
return SizedBox( return SizedBox(
width: 34, width: 34,
height: 34, height: 34,
child: IconButton( child: InkWell(
tooltip: tooltip, onTap: () {
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
fuc!(); fuc!();
}, },
icon: icon!, child: icon!,
), ),
); );
} }

View File

@@ -66,25 +66,23 @@ class PlayOrPauseButtonState extends State<PlayOrPauseButton>
return SizedBox( return SizedBox(
width: 42, width: 42,
height: 34, height: 34,
child: IconButton( child: InkWell(
tooltip: widget.controller!.videoPlayerController!.state.playing onTap: player.playOrPause,
? '暂停'
: '播放',
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: player.playOrPause,
color: Colors.white,
iconSize: 25,
// iconSize: widget.iconSize ?? _theme(context).buttonBarButtonSize, // iconSize: widget.iconSize ?? _theme(context).buttonBarButtonSize,
// color: widget.iconColor ?? _theme(context).buttonBarButtonColor, // color: widget.iconColor ?? _theme(context).buttonBarButtonColor,
icon: AnimatedIcon( child: Center(
progress: animation, child: AnimatedIcon(
icon: AnimatedIcons.play_pause, semanticLabel:
color: Colors.white, widget.controller!.videoPlayerController!.state.playing
size: 20, ? '暂停'
// size: widget.iconSize ?? _theme(context).buttonBarButtonSize, : '播放',
// color: widget.iconColor ?? _theme(context).buttonBarButtonColor, progress: animation,
icon: AnimatedIcons.play_pause,
color: Colors.white,
size: 20,
// size: widget.iconSize ?? _theme(context).buttonBarButtonSize,
// color: widget.iconColor ?? _theme(context).buttonBarButtonColor,
),
), ),
), ),
); );