Skip to content

Commit 7dded2d

Browse files
committed
Merge commit '0a390f93ff98010cbc97ae7017dd064045221448' into custom-lg
* commit '0a390f93ff98010cbc97ae7017dd064045221448': chewie, version 1.11.1. Addresses Issues fluttercommunity#875, fluttercommunity#896, and fluttercommunity#910. Fix example on web Add background tap to pause formatted with dart 3.27 reverted formatting Fixed allowMute being ignored on Desktop # Conflicts: # lib/src/chewie_player.dart
2 parents e7f759e + 0a390f9 commit 7dded2d

File tree

8 files changed

+50
-18
lines changed

8 files changed

+50
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [1.11.1]
2+
* ⬆️ [#875](https://github.com/fluttercommunity/chewie/pull/875): Add background tap to pause video feature. Thanks [Ortes](https://github.com/Ortes).
3+
* 🛠️ [#896](https://github.com/fluttercommunity/chewie/pull/896): Fixed allowMute being ignored on Desktop. Thanks [mpoimer](https://github.com/mpoimer).
4+
* 🛠️ [#910](https://github.com/fluttercommunity/chewie/pull/910): Fix example on web. Thanks [Ortes](https://github.com/Ortes).
5+
16
## [1.11.0]
27
* ⬆️ [#900](https://github.com/fluttercommunity/chewie/pull/900): Flutter `3.29` upgrade. Thanks [diegotori](https://github.com/diegotori).
38
* **BREAKING CHANGE**: Library now requires at least Flutter version `3.27.0`, for real this time.

example/lib/app/app.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:io';
21

32
import 'package:chewie/chewie.dart';
43
import 'package:chewie_example/app/theme.dart';
@@ -312,7 +311,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
312311
),
313312
],
314313
),
315-
if (Platform.isAndroid)
314+
if (Theme.of(context).platform == TargetPlatform.android)
316315
ListTile(
317316
title: const Text("Delay"),
318317
subtitle: DelaySlider(

example/lib/my_test_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class _MyDemoState extends State<MyDemo> {
6666
// ),
6767
autoInitialize: true,
6868
deviceOrientationsAfterFullScreen: [DeviceOrientation.portraitUp],
69+
// pauseOnBackgroundTap: true,
6970
);
7071

7172
_logListener = () {

lib/src/chewie_player.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ class ChewieController extends ChangeNotifier {
322322
this.progressIndicatorDelay,
323323
this.hideControlsTimer = defaultHideControlsTimer,
324324
this.controlsSafeAreaMinimum = EdgeInsets.zero,
325+
this.pauseOnBackgroundTap = false,
325326
}) : assert(
326327
playbackSpeeds.every((speed) => speed > 0),
327328
'The playbackSpeeds values must all be greater than 0',
@@ -378,8 +379,8 @@ class ChewieController extends ChangeNotifier {
378379
Animation<double>,
379380
Animation<double>,
380381
ChewieControllerProvider,
381-
)?
382-
routePageBuilder,
382+
)? routePageBuilder,
383+
bool? pauseOnBackgroundTap,
383384
}) {
384385
return ChewieController(
385386
draggableProgressBar: draggableProgressBar ?? this.draggableProgressBar,
@@ -435,6 +436,7 @@ class ChewieController extends ChangeNotifier {
435436
hideControlsTimer: hideControlsTimer ?? this.hideControlsTimer,
436437
progressIndicatorDelay:
437438
progressIndicatorDelay ?? this.progressIndicatorDelay,
439+
pauseOnBackgroundTap: pauseOnBackgroundTap ?? this.pauseOnBackgroundTap,
438440
);
439441
}
440442

@@ -599,6 +601,9 @@ class ChewieController extends ChangeNotifier {
599601
/// Defaults to [EdgeInsets.zero].
600602
final EdgeInsets controlsSafeAreaMinimum;
601603

604+
/// Defines if the player should pause when the background is tapped
605+
final bool pauseOnBackgroundTap;
606+
602607
static ChewieController of(BuildContext context) {
603608
final chewieControllerProvider =
604609
context.dependOnInheritedWidgetOfExactType<ChewieControllerProvider>()!;

lib/src/cupertino/cupertino_controls.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,15 @@ class _CupertinoControlsState extends State<CupertinoControls>
354354

355355
return GestureDetector(
356356
onTap: _latestValue.isPlaying
357-
? _cancelAndRestartTimer
357+
? _chewieController?.pauseOnBackgroundTap ?? false
358+
? () {
359+
_playPause();
360+
361+
setState(() {
362+
notifier.hideStuff = true;
363+
});
364+
}
365+
: _cancelAndRestartTimer
358366
: () {
359367
_hideTimer?.cancel();
360368

lib/src/material/material_controls.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,17 @@ class _MaterialControlsState extends State<MaterialControls>
380380
return GestureDetector(
381381
onTap: () {
382382
if (_latestValue.isPlaying) {
383-
if (_displayTapped) {
384-
setState(() {
385-
notifier.hideStuff = true;
386-
});
387-
} else {
383+
if (_chewieController?.pauseOnBackgroundTap ?? false) {
384+
_playPause();
388385
_cancelAndRestartTimer();
386+
} else {
387+
if (_displayTapped) {
388+
setState(() {
389+
notifier.hideStuff = true;
390+
});
391+
} else {
392+
_cancelAndRestartTimer();
393+
}
389394
}
390395
} else {
391396
_playPause();

lib/src/material/material_desktop_controls.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
106106
_cancelAndRestartTimer();
107107
},
108108
child: GestureDetector(
109-
onTap: () => _cancelAndRestartTimer(),
109+
onTap: () {
110+
_playPause();
111+
_cancelAndRestartTimer();
112+
},
110113
child: AbsorbPointer(
111114
absorbing: notifier.hideStuff,
112115
child: Stack(
@@ -291,7 +294,8 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
291294
child: Row(
292295
children: <Widget>[
293296
_buildPlayPause(controller),
294-
_buildMuteButton(controller),
297+
if (chewieController.allowMuting)
298+
_buildMuteButton(controller),
295299
if (chewieController.isLive)
296300
const Expanded(child: Text('LIVE'))
297301
else
@@ -364,12 +368,17 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
364368
return GestureDetector(
365369
onTap: () {
366370
if (_latestValue.isPlaying) {
367-
if (_displayTapped) {
368-
setState(() {
369-
notifier.hideStuff = true;
370-
});
371-
} else {
371+
if (_chewieController?.pauseOnBackgroundTap ?? false) {
372+
_playPause();
372373
_cancelAndRestartTimer();
374+
} else {
375+
if (_displayTapped) {
376+
setState(() {
377+
notifier.hideStuff = true;
378+
});
379+
} else {
380+
_cancelAndRestartTimer();
381+
}
373382
}
374383
} else {
375384
_playPause();

pubspec.yaml

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

66
environment:

0 commit comments

Comments
 (0)