Skip to content

Commit afa4171

Browse files
authored
Merge branch 'fluttercommunity:master' into master
2 parents d07a5de + 398c1ad commit afa4171

10 files changed

+119
-44
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [1.9.0]
2+
* **BREAKING CHANGE**: Library now requires at least Flutter version `3.27.0`.
3+
4+
## [1.8.7]
5+
* ⬆️ [#876](https://github.com/fluttercommunity/chewie/pull/876): Add keyboard controls seek forward and backward and fullscreen escape on desktop. Thanks [Ortes](https://github.com/Ortes).
6+
7+
## [1.8.6]
8+
* ⬆️ [#874](https://github.com/fluttercommunity/chewie/pull/874): Add `devtools_options.yaml` configuration files. Thanks [MoRmdn](https://github.com/MoRmdn).
9+
110
## [1.8.5]
211
* ⬆️ [#703](https://github.com/fluttercommunity/chewie/pull/703): Adding Seek buttons for Android. Thanks [GyanendroKh](https://github.com/GyanendroKh).
312
* Upgraded `wakelock_plus` to version `1.2.8`, which uses `web` version `1.0.0`. Thanks [diegotori](https://github.com/diegotori).

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ dependencies:
3333
3434
```dart
3535
import 'package:chewie/chewie.dart';
36+
import 'package:video_player/video_player.dart';
37+
3638
final videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(
3739
'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4'));
3840

devtools_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: This file stores settings for Dart & Flutter DevTools.
2+
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
3+
extensions:

example/devtools_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: This file stores settings for Dart & Flutter DevTools.
2+
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
3+
extensions:

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Flutter
22
import UIKit
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

lib/src/cupertino/cupertino_controls.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
460460
final position = _latestValue.duration - _latestValue.position;
461461

462462
return Padding(
463-
padding: const EdgeInsets.only(right: 12.0),
463+
padding: const EdgeInsets.symmetric(horizontal: 12.0),
464464
child: Text(
465465
'-${formatDuration(position)}',
466466
style: TextStyle(color: iconColor, fontSize: 12.0),

lib/src/helpers/adaptive_controls.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class AdaptiveControls extends StatelessWidget {
2323
backgroundColor: Color.fromRGBO(41, 41, 41, 0.7),
2424
iconColor: Color.fromARGB(255, 200, 200, 200),
2525
);
26-
default:
27-
return const MaterialControls();
2826
}
2927
}
3028
}

lib/src/material/material_controls.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ class _MaterialControlsState extends State<MaterialControls>
260260
height: barHeight + (chewieController.isFullScreen ? 10.0 : 0),
261261
padding: EdgeInsets.only(
262262
left: 20,
263+
right: 20,
263264
bottom: !chewieController.isFullScreen ? 10.0 : 0,
264265
),
265266
child: SafeArea(
@@ -291,7 +292,7 @@ class _MaterialControlsState extends State<MaterialControls>
291292
if (!chewieController.isLive)
292293
Expanded(
293294
child: Container(
294-
padding: const EdgeInsets.only(right: 20),
295+
padding: const EdgeInsets.symmetric(horizontal: 20),
295296
child: Row(
296297
children: [
297298
_buildProgressBar(),
@@ -469,7 +470,7 @@ class _MaterialControlsState extends State<MaterialControls>
469470
text: '/ ${formatDuration(duration)}',
470471
style: TextStyle(
471472
fontSize: 14.0,
472-
color: Colors.white.withOpacity(.75),
473+
color: Colors.white.withValues(alpha: .75),
473474
fontWeight: FontWeight.normal,
474475
),
475476
)
@@ -682,8 +683,9 @@ class _MaterialControlsState extends State<MaterialControls>
682683
playedColor: Theme.of(context).colorScheme.secondary,
683684
handleColor: Theme.of(context).colorScheme.secondary,
684685
bufferedColor:
685-
Theme.of(context).colorScheme.surface.withOpacity(0.5),
686-
backgroundColor: Theme.of(context).disabledColor.withOpacity(.5),
686+
Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
687+
backgroundColor:
688+
Theme.of(context).disabledColor.withValues(alpha: .5),
687689
),
688690
draggableProgressBar: chewieController.draggableProgressBar,
689691
),

lib/src/material/material_desktop_controls.dart

Lines changed: 92 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:chewie/src/models/option_item.dart';
1212
import 'package:chewie/src/models/subtitle_model.dart';
1313
import 'package:chewie/src/notifiers/index.dart';
1414
import 'package:flutter/material.dart';
15+
import 'package:flutter/services.dart';
1516
import 'package:provider/provider.dart';
1617
import 'package:video_player/video_player.dart';
1718

@@ -49,16 +50,36 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
4950

5051
late VideoPlayerController controller;
5152
ChewieController? _chewieController;
53+
late final FocusNode _focusNode;
5254

5355
// We know that _chewieController is set in didChangeDependencies
5456
ChewieController get chewieController => _chewieController!;
5557

5658
@override
5759
void initState() {
5860
super.initState();
61+
_focusNode = FocusNode();
62+
_focusNode.requestFocus();
5963
notifier = Provider.of<PlayerNotifier>(context, listen: false);
6064
}
6165

66+
void _handleKeyPress(event) {
67+
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.space) {
68+
_playPause();
69+
} else if (event is KeyDownEvent &&
70+
event.logicalKey == LogicalKeyboardKey.arrowRight) {
71+
_seekForward();
72+
} else if (event is KeyDownEvent &&
73+
event.logicalKey == LogicalKeyboardKey.arrowLeft) {
74+
_seekBackward();
75+
} else if (event is KeyDownEvent &&
76+
event.logicalKey == LogicalKeyboardKey.escape) {
77+
if (chewieController.isFullScreen) {
78+
_onExpandCollapse();
79+
}
80+
}
81+
}
82+
6283
@override
6384
Widget build(BuildContext context) {
6485
if (_latestValue.hasError) {
@@ -75,39 +96,44 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
7596
);
7697
}
7798

78-
return MouseRegion(
79-
onHover: (_) {
80-
_cancelAndRestartTimer();
81-
},
82-
child: GestureDetector(
83-
onTap: () => _cancelAndRestartTimer(),
84-
child: AbsorbPointer(
85-
absorbing: notifier.hideStuff,
86-
child: Stack(
87-
children: [
88-
if (_displayBufferingIndicator)
89-
_chewieController?.bufferingBuilder?.call(context) ??
90-
const Center(
91-
child: CircularProgressIndicator(),
92-
)
93-
else
94-
_buildHitArea(),
95-
Column(
96-
mainAxisAlignment: MainAxisAlignment.end,
97-
children: <Widget>[
98-
if (_subtitleOn)
99-
Transform.translate(
100-
offset: Offset(
101-
0.0,
102-
notifier.hideStuff ? barHeight * 0.8 : 0.0,
99+
return KeyboardListener(
100+
focusNode: _focusNode,
101+
onKeyEvent: _handleKeyPress,
102+
child: MouseRegion(
103+
onHover: (_) {
104+
_focusNode.requestFocus();
105+
_cancelAndRestartTimer();
106+
},
107+
child: GestureDetector(
108+
onTap: () => _cancelAndRestartTimer(),
109+
child: AbsorbPointer(
110+
absorbing: notifier.hideStuff,
111+
child: Stack(
112+
children: [
113+
if (_displayBufferingIndicator)
114+
_chewieController?.bufferingBuilder?.call(context) ??
115+
const Center(
116+
child: CircularProgressIndicator(),
117+
)
118+
else
119+
_buildHitArea(),
120+
Column(
121+
mainAxisAlignment: MainAxisAlignment.end,
122+
children: <Widget>[
123+
if (_subtitleOn)
124+
Transform.translate(
125+
offset: Offset(
126+
0.0,
127+
notifier.hideStuff ? barHeight * 0.8 : 0.0,
128+
),
129+
child: _buildSubtitles(
130+
context, chewieController.subtitle!),
103131
),
104-
child:
105-
_buildSubtitles(context, chewieController.subtitle!),
106-
),
107-
_buildBottomBar(context),
108-
],
109-
),
110-
],
132+
_buildBottomBar(context),
133+
],
134+
),
135+
],
136+
),
111137
),
112138
),
113139
),
@@ -117,6 +143,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
117143
@override
118144
void dispose() {
119145
_dispose();
146+
_focusNode.dispose();
120147
super.dispose();
121148
}
122149

@@ -566,6 +593,36 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
566593
});
567594
}
568595

596+
void _seekBackward() {
597+
_seekRelative(
598+
const Duration(
599+
seconds: -10,
600+
),
601+
);
602+
}
603+
604+
void _seekForward() {
605+
_seekRelative(
606+
const Duration(
607+
seconds: 10,
608+
),
609+
);
610+
}
611+
612+
void _seekRelative(Duration relativeSeek) {
613+
_cancelAndRestartTimer();
614+
final position = _latestValue.position + relativeSeek;
615+
final duration = _latestValue.duration;
616+
617+
if (position < Duration.zero) {
618+
controller.seekTo(Duration.zero);
619+
} else if (position > duration) {
620+
controller.seekTo(duration);
621+
} else {
622+
controller.seekTo(position);
623+
}
624+
}
625+
569626
Widget _buildProgressBar() {
570627
return Expanded(
571628
child: MaterialVideoProgressBar(
@@ -592,8 +649,9 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
592649
playedColor: Theme.of(context).colorScheme.secondary,
593650
handleColor: Theme.of(context).colorScheme.secondary,
594651
bufferedColor:
595-
Theme.of(context).colorScheme.surface.withOpacity(0.5),
596-
backgroundColor: Theme.of(context).disabledColor.withOpacity(.5),
652+
Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
653+
backgroundColor:
654+
Theme.of(context).disabledColor.withValues(alpha: 0.5),
597655
),
598656
draggableProgressBar: chewieController.draggableProgressBar,
599657
),

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: chewie
22
description: A video player for Flutter with Cupertino and Material play controls
3-
version: 1.8.5
3+
version: 1.9.0
44
homepage: https://github.com/fluttercommunity/chewie
55

66
environment:
77
sdk: '>=3.3.0 <4.0.0'
8-
flutter: ">=3.19.0"
8+
flutter: ">=3.27.0"
99

1010
dependencies:
1111
cupertino_icons: ^1.0.5

0 commit comments

Comments
 (0)