Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ env:
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
# Note: The version below should be manually updated to the latest second most recent version
# after a new stable version comes out.
# Current minimum is set to Flutter 3.29. Make this the new minimum once the next
# Current minimum is set to Flutter 3.32. Make the next version the new minimum once the next
# stable version is released
FLUTTER_VERSION_MINIMUM_DEFAULT: "3.29.3"
FLUTTER_VERSION_MINIMUM_DEFAULT: "3.32.8"
FLUTTER_VERSION_LATEST_STABLE_CHANNEL_DEFAULT: "3.x"

jobs:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
# Only continue on error if this is the job for the MINIMUM Flutter version
# This allows formatting issues to be warnings on older supported versions
# but enforces them on the latest stable or primary development version.
continue-on-error: ${{ matrix.flutter-version == env.FLUTTER_VERSION_MINIMUM }}
continue-on-error: "${{ matrix.flutter-version == env.FLUTTER_VERSION_MINIMUM }}"

- name: 🕵️ Analyze
run: flutter analyze lib
Expand All @@ -93,4 +93,4 @@ jobs:
- name: 📁 Upload coverage to Codecov
uses: codecov/codecov-action@v5
# TODO: Remove the below once we have adequate tests for this library.
continue-on-error: true
continue-on-error: "true"
12 changes: 8 additions & 4 deletions example/lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ class _ChewieDemoState extends State<ChewieDemo> {
autoPlay: true,
zoomAndPan: true,
looping: true,
progressIndicatorDelay:
bufferDelay != null ? Duration(milliseconds: bufferDelay!) : null,
progressIndicatorDelay: bufferDelay != null
? Duration(milliseconds: bufferDelay!)
: null,

additionalOptions: (context) {
return <OptionItem>[
Expand Down Expand Up @@ -177,9 +178,12 @@ class _ChewieDemoState extends State<ChewieDemo> {
children: <Widget>[
Expanded(
child: Center(
child: _chewieController != null &&
child:
_chewieController != null &&
_chewieController!
.videoPlayerController.value.isInitialized
.videoPlayerController
.value
.isInitialized
? Chewie(controller: _chewieController!)
: const Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ version: 1.0.0
publish_to: none

environment:
sdk: '>=3.6.0 <4.0.0'
flutter: ">=3.27.0"
sdk: '>=3.8.0 <4.0.0'
flutter: ">=3.32.0"

dependencies:
chewie:
path: ../
flutter:
sdk: flutter
video_player: ^2.9.3
video_player: ^2.10.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
Expand Down
10 changes: 3 additions & 7 deletions lib/src/center_play_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ class CenterPlayButton extends StatelessWidget {
child: IconButton(
iconSize: 32,
padding: const EdgeInsets.all(12.0),
icon:
isFinished
? Icon(Icons.replay, color: iconColor)
: AnimatedPlayPause(
color: iconColor,
playing: isPlaying,
),
icon: isFinished
? Icon(Icons.replay, color: iconColor)
: AnimatedPlayPause(color: iconColor, playing: isPlaying),
onPressed: onPressed,
),
),
Expand Down
9 changes: 4 additions & 5 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ChewieState extends State<Chewie> {
builder: (context, w) => const PlayerWithControls(),
),
);

if (kIsWeb && !_resumeAppliedInFullScreen) {
_resumeAppliedInFullScreen = true;
WidgetsBinding.instance.addPostFrameCallback((_) async {
Expand Down Expand Up @@ -187,8 +187,7 @@ class ChewieState extends State<Chewie> {
rootNavigator: widget.controller.useRootNavigator,
).push(route);

final wasPlaying =
widget.controller.videoPlayerController.value.isPlaying;
final wasPlaying = widget.controller.videoPlayerController.value.isPlaying;

if (kIsWeb) {
await _reInitializeControllers(wasPlaying);
Expand Down Expand Up @@ -632,8 +631,8 @@ class ChewieController extends ChangeNotifier {
final bool pauseOnBackgroundTap;

static ChewieController of(BuildContext context) {
final chewieControllerProvider =
context.dependOnInheritedWidgetOfExactType<ChewieControllerProvider>()!;
final chewieControllerProvider = context
.dependOnInheritedWidgetOfExactType<ChewieControllerProvider>()!;

return chewieControllerProvider.controller;
}
Expand Down
167 changes: 78 additions & 89 deletions lib/src/cupertino/cupertino_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ class _CupertinoControlsState extends State<CupertinoControls>
if (_latestValue.hasError) {
return chewieController.errorBuilder != null
? chewieController.errorBuilder!(
context,
chewieController.videoPlayerController.value.errorDescription!,
)
context,
chewieController.videoPlayerController.value.errorDescription!,
)
: const Center(
child: Icon(
CupertinoIcons.exclamationmark_circle,
color: Colors.white,
size: 42,
),
);
child: Icon(
CupertinoIcons.exclamationmark_circle,
color: Colors.white,
size: 42,
),
);
}

final backgroundColor = widget.backgroundColor;
Expand Down Expand Up @@ -172,12 +172,11 @@ class _CupertinoControlsState extends State<CupertinoControls>
context: context,
semanticsDismissible: true,
useRootNavigator: chewieController.useRootNavigator,
builder:
(context) => CupertinoOptionsDialog(
options: options,
cancelButtonText:
chewieController.optionsTranslation?.cancelButtonText,
),
builder: (context) => CupertinoOptionsDialog(
options: options,
cancelButtonText:
chewieController.optionsTranslation?.cancelButtonText,
),
);
if (_latestValue.isPlaying) {
_startHideTimer();
Expand Down Expand Up @@ -252,37 +251,32 @@ class _CupertinoControlsState extends State<CupertinoControls>
child: Container(
height: barHeight,
color: backgroundColor,
child:
chewieController.isLive
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
_buildPlayPause(controller, iconColor, barHeight),
_buildLive(iconColor),
],
)
: Row(
children: <Widget>[
_buildSkipBack(iconColor, barHeight),
_buildPlayPause(controller, iconColor, barHeight),
_buildSkipForward(iconColor, barHeight),
_buildPosition(iconColor),
_buildProgressBar(),
_buildRemaining(iconColor),
_buildSubtitleToggle(iconColor, barHeight),
if (chewieController.allowPlaybackSpeedChanging)
_buildSpeedButton(
controller,
iconColor,
barHeight,
),
if (chewieController.additionalOptions != null &&
chewieController
.additionalOptions!(context)
.isNotEmpty)
_buildOptionsButton(iconColor, barHeight),
],
),
child: chewieController.isLive
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
_buildPlayPause(controller, iconColor, barHeight),
_buildLive(iconColor),
],
)
: Row(
children: <Widget>[
_buildSkipBack(iconColor, barHeight),
_buildPlayPause(controller, iconColor, barHeight),
_buildSkipForward(iconColor, barHeight),
_buildPosition(iconColor),
_buildProgressBar(),
_buildRemaining(iconColor),
_buildSubtitleToggle(iconColor, barHeight),
if (chewieController.allowPlaybackSpeedChanging)
_buildSpeedButton(controller, iconColor, barHeight),
if (chewieController.additionalOptions != null &&
chewieController
.additionalOptions!(context)
.isNotEmpty)
_buildOptionsButton(iconColor, barHeight),
],
),
),
),
),
Expand Down Expand Up @@ -344,24 +338,23 @@ class _CupertinoControlsState extends State<CupertinoControls>
widget.showPlayButton && !_latestValue.isPlaying && !_dragging;

return GestureDetector(
onTap:
_latestValue.isPlaying
? _chewieController?.pauseOnBackgroundTap ?? false
? () {
onTap: _latestValue.isPlaying
? _chewieController?.pauseOnBackgroundTap ?? false
? () {
_playPause();

setState(() {
notifier.hideStuff = true;
});
}
: _cancelAndRestartTimer
: () {
_hideTimer?.cancel();

setState(() {
notifier.hideStuff = false;
});
},
: _cancelAndRestartTimer
: () {
_hideTimer?.cancel();

setState(() {
notifier.hideStuff = false;
});
},
child: CenterPlayButton(
backgroundColor: widget.backgroundColor,
iconColor: widget.iconColor,
Expand Down Expand Up @@ -528,11 +521,10 @@ class _CupertinoControlsState extends State<CupertinoControls>
context: context,
semanticsDismissible: true,
useRootNavigator: chewieController.useRootNavigator,
builder:
(context) => _PlaybackSpeedDialog(
speeds: chewieController.playbackSpeeds,
selected: _latestValue.playbackSpeed,
),
builder: (context) => _PlaybackSpeedDialog(
speeds: chewieController.playbackSpeeds,
selected: _latestValue.playbackSpeed,
),
);

if (chosenSpeed != null) {
Expand All @@ -552,10 +544,9 @@ class _CupertinoControlsState extends State<CupertinoControls>
margin: const EdgeInsets.only(right: 8.0),
child: Transform(
alignment: Alignment.center,
transform:
Matrix4.skewY(0.0)
..rotateX(math.pi)
..rotateZ(math.pi * 0.8),
transform: Matrix4.skewY(0.0)
..rotateX(math.pi)
..rotateZ(math.pi * 0.8),
child: Icon(Icons.speed, color: iconColor, size: 18.0),
),
),
Expand Down Expand Up @@ -733,10 +724,9 @@ class _CupertinoControlsState extends State<CupertinoControls>
}

void _startHideTimer() {
final hideControlsTimer =
chewieController.hideControlsTimer.isNegative
? ChewieController.defaultHideControlsTimer
: chewieController.hideControlsTimer;
final hideControlsTimer = chewieController.hideControlsTimer.isNegative
? ChewieController.defaultHideControlsTimer
: chewieController.hideControlsTimer;
_hideTimer = Timer(hideControlsTimer, () {
setState(() {
notifier.hideStuff = true;
Expand Down Expand Up @@ -794,24 +784,23 @@ class _PlaybackSpeedDialog extends StatelessWidget {
final selectedColor = CupertinoTheme.of(context).primaryColor;

return CupertinoActionSheet(
actions:
_speeds
.map(
(e) => CupertinoActionSheetAction(
onPressed: () {
Navigator.of(context).pop(e);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (e == _selected)
Icon(Icons.check, size: 20.0, color: selectedColor),
Text(e.toString()),
],
),
),
)
.toList(),
actions: _speeds
.map(
(e) => CupertinoActionSheetAction(
onPressed: () {
Navigator.of(context).pop(e);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (e == _selected)
Icon(Icons.check, size: 20.0, color: selectedColor),
Text(e.toString()),
],
),
),
)
.toList(),
);
}
}
17 changes: 8 additions & 9 deletions lib/src/cupertino/widgets/cupertino_options_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ class _CupertinoOptionsDialogState extends State<CupertinoOptionsDialog> {
Widget build(BuildContext context) {
return SafeArea(
child: CupertinoActionSheet(
actions:
widget.options
.map(
(option) => CupertinoActionSheetAction(
onPressed: () => option.onTap(context),
child: Text(option.title),
),
)
.toList(),
actions: widget.options
.map(
(option) => CupertinoActionSheetAction(
onPressed: () => option.onTap(context),
child: Text(option.title),
),
)
.toList(),
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(context),
isDestructiveAction: true,
Expand Down
Loading