Skip to content

Commit ade5079

Browse files
committed
Fixed allowMute being ignored on Desktop
1 parent 483e22b commit ade5079

File tree

1 file changed

+22
-46
lines changed

1 file changed

+22
-46
lines changed

lib/src/material/material_desktop_controls.dart

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class MaterialDesktopControls extends StatefulWidget {
3131
}
3232
}
3333

34-
class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
35-
with SingleTickerProviderStateMixin {
34+
class _MaterialDesktopControlsState extends State<MaterialDesktopControls> with SingleTickerProviderStateMixin {
3635
late PlayerNotifier notifier;
3736
late VideoPlayerValue _latestValue;
3837
double? _latestVolume;
@@ -67,14 +66,11 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
6766
void _handleKeyPress(event) {
6867
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.space) {
6968
_playPause();
70-
} else if (event is KeyDownEvent &&
71-
event.logicalKey == LogicalKeyboardKey.arrowRight) {
69+
} else if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.arrowRight) {
7270
_seekForward();
73-
} else if (event is KeyDownEvent &&
74-
event.logicalKey == LogicalKeyboardKey.arrowLeft) {
71+
} else if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.arrowLeft) {
7572
_seekBackward();
76-
} else if (event is KeyDownEvent &&
77-
event.logicalKey == LogicalKeyboardKey.escape) {
73+
} else if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.escape) {
7874
if (chewieController.isFullScreen) {
7975
_onExpandCollapse();
8076
}
@@ -127,8 +123,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
127123
0.0,
128124
notifier.hideStuff ? barHeight * 0.8 : 0.0,
129125
),
130-
child: _buildSubtitles(
131-
context, chewieController.subtitle!),
126+
child: _buildSubtitles(context, chewieController.subtitle!),
132127
),
133128
_buildBottomBar(context),
134129
],
@@ -188,13 +183,11 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
188183
_onSpeedButtonTap();
189184
},
190185
iconData: Icons.speed,
191-
title: chewieController.optionsTranslation?.playbackSpeedButtonText ??
192-
'Playback speed',
186+
title: chewieController.optionsTranslation?.playbackSpeedButtonText ?? 'Playback speed',
193187
)
194188
];
195189

196-
if (chewieController.additionalOptions != null &&
197-
chewieController.additionalOptions!(context).isNotEmpty) {
190+
if (chewieController.additionalOptions != null && chewieController.additionalOptions!(context).isNotEmpty) {
198191
options.addAll(chewieController.additionalOptions!(context));
199192
}
200193

@@ -215,8 +208,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
215208
useRootNavigator: chewieController.useRootNavigator,
216209
builder: (context) => OptionsDialog(
217210
options: options,
218-
cancelButtonText:
219-
chewieController.optionsTranslation?.cancelButtonText,
211+
cancelButtonText: chewieController.optionsTranslation?.cancelButtonText,
220212
),
221213
);
222214
}
@@ -278,8 +270,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
278270
duration: const Duration(milliseconds: 300),
279271
child: Container(
280272
height: barHeight + (chewieController.isFullScreen ? 20.0 : 0),
281-
padding:
282-
EdgeInsets.only(bottom: chewieController.isFullScreen ? 10.0 : 15),
273+
padding: EdgeInsets.only(bottom: chewieController.isFullScreen ? 10.0 : 15),
283274
child: SafeArea(
284275
bottom: chewieController.isFullScreen,
285276
child: Column(
@@ -291,18 +282,12 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
291282
child: Row(
292283
children: <Widget>[
293284
_buildPlayPause(controller),
294-
_buildMuteButton(controller),
295-
if (chewieController.isLive)
296-
const Expanded(child: Text('LIVE'))
297-
else
298-
_buildPosition(iconColor),
285+
if (chewieController.allowMuting) _buildMuteButton(controller),
286+
if (chewieController.isLive) const Expanded(child: Text('LIVE')) else _buildPosition(iconColor),
299287
const Spacer(),
300-
if (chewieController.showControls &&
301-
chewieController.subtitle != null &&
302-
chewieController.subtitle!.isNotEmpty)
288+
if (chewieController.showControls && chewieController.subtitle != null && chewieController.subtitle!.isNotEmpty)
303289
_buildSubtitleToggle(icon: Icons.subtitles),
304-
if (chewieController.showOptions)
305-
_buildOptionsButton(icon: Icons.settings),
290+
if (chewieController.showOptions) _buildOptionsButton(icon: Icons.settings),
306291
if (chewieController.allowFullScreen) _buildExpandButton(),
307292
],
308293
),
@@ -344,9 +329,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
344329
),
345330
child: Center(
346331
child: Icon(
347-
chewieController.isFullScreen
348-
? Icons.fullscreen_exit
349-
: Icons.fullscreen,
332+
chewieController.isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen,
350333
color: Colors.white,
351334
),
352335
),
@@ -356,10 +339,8 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
356339
}
357340

358341
Widget _buildHitArea() {
359-
final bool isFinished = _latestValue.position >= _latestValue.duration &&
360-
_latestValue.duration.inSeconds > 0;
361-
final bool showPlayButton =
362-
widget.showPlayButton && !_dragging && !notifier.hideStuff;
342+
final bool isFinished = _latestValue.position >= _latestValue.duration && _latestValue.duration.inSeconds > 0;
343+
final bool showPlayButton = widget.showPlayButton && !_dragging && !notifier.hideStuff;
363344

364345
return GestureDetector(
365346
onTap: () {
@@ -494,8 +475,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
494475
}
495476

496477
Future<void> _initialize() async {
497-
_subtitleOn = chewieController.showSubtitles &&
498-
(chewieController.subtitle?.isNotEmpty ?? false);
478+
_subtitleOn = chewieController.showSubtitles && (chewieController.subtitle?.isNotEmpty ?? false);
499479
controller.addListener(_updateState);
500480

501481
_updateState();
@@ -520,8 +500,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
520500

521501
chewieController.toggleFullScreen();
522502

523-
_showAfterExpandCollapseTimer =
524-
Timer(const Duration(milliseconds: 300), () {
503+
_showAfterExpandCollapseTimer = Timer(const Duration(milliseconds: 300), () {
525504
setState(() {
526505
_cancelAndRestartTimer();
527506
});
@@ -552,9 +531,8 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
552531
}
553532

554533
void _startHideTimer() {
555-
final hideControlsTimer = chewieController.hideControlsTimer.isNegative
556-
? ChewieController.defaultHideControlsTimer
557-
: chewieController.hideControlsTimer;
534+
final hideControlsTimer =
535+
chewieController.hideControlsTimer.isNegative ? ChewieController.defaultHideControlsTimer : chewieController.hideControlsTimer;
558536
_hideTimer = Timer(hideControlsTimer, () {
559537
setState(() {
560538
notifier.hideStuff = true;
@@ -649,10 +627,8 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
649627
ChewieProgressColors(
650628
playedColor: Theme.of(context).colorScheme.secondary,
651629
handleColor: Theme.of(context).colorScheme.secondary,
652-
bufferedColor:
653-
Theme.of(context).colorScheme.surface.withOpacityCompat(0.5),
654-
backgroundColor:
655-
Theme.of(context).disabledColor.withOpacityCompat(0.5),
630+
bufferedColor: Theme.of(context).colorScheme.surface.withOpacityCompat(0.5),
631+
backgroundColor: Theme.of(context).disabledColor.withOpacityCompat(0.5),
656632
),
657633
draggableProgressBar: chewieController.draggableProgressBar,
658634
),

0 commit comments

Comments
 (0)