Skip to content

Commit 39f06c5

Browse files
authored
Merge branch 'fluttercommunity:master' into fix-pop
2 parents 4238c69 + c2a54c3 commit 39f06c5

File tree

14 files changed

+296
-106
lines changed

14 files changed

+296
-106
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,51 @@ on:
1111
- '**.md'
1212
workflow_dispatch:
1313

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
1418
jobs:
15-
check-format:
16-
name: Check format using dart format.
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
- name: Flutter Action
23-
uses: subosito/flutter-action@v2
24-
- name: Check format
25-
run: dart format . --set-exit-if-changed
26-
27-
lint:
28-
name: Lint
19+
# Does a sanity check that packages at least pass analysis on the N-1
20+
# versions of Flutter stable if the package claims to support that version.
21+
# This is to minimize accidentally making changes that break old versions
22+
# (which we don't commit to supporting, but don't want to actively break)
23+
# without updating the constraints.
24+
lint_and_build:
25+
name: Flutter Version ${{ matrix.flutter-version }} Lint and Build.
2926
runs-on: ubuntu-latest
30-
27+
strategy:
28+
matrix:
29+
flutter-version:
30+
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
31+
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
32+
# Note: The version below should be manually updated to the latest second most recent version
33+
# after a new stable version comes out.
34+
- "3.24.5"
35+
- "3.x"
3136
steps:
32-
- name: Checkout code
37+
- name: 📚 Git Checkout
3338
uses: actions/checkout@v4
34-
- name: Flutter Action
39+
40+
- name: 🐦 Setup Flutter
3541
uses: subosito/flutter-action@v2
36-
- name: Install Package Dependencies
42+
with:
43+
flutter-version: ${{ matrix.flutter-version }}
44+
channel: stable
45+
cache: true
46+
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
47+
48+
- name: 📦 Install Dependencies
3749
run: flutter packages get
38-
- name: Get dependencies for example
39-
run: flutter pub get
40-
working-directory: example
41-
- name: Lint using flutter analyze
42-
run: flutter analyze .
43-
44-
test:
45-
name: Run tests.
46-
runs-on: ubuntu-latest
4750

48-
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v4
51-
- name: Flutter Action
52-
uses: subosito/flutter-action@v2
53-
- name: Run flutter test
54-
run: |
55-
flutter pub get
56-
flutter test
51+
- name: ✨ Check Formatting
52+
run: dart format --set-exit-if-changed lib
53+
54+
- name: 🕵️ Analyze
55+
run: flutter analyze lib
56+
57+
- name: 🧪 Run Tests
58+
run: flutter test --no-pub --coverage --test-randomize-ordering-seed random
59+
60+
- name: 📁 Upload coverage to Codecov
61+
uses: codecov/codecov-action@v5

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## [1.9.2]
2+
* Fixed broken Table of Contents links in `README.md`, take two.
3+
4+
## [1.9.1+1]
5+
* Fixed broken Table of Contents links in `README.md`.
6+
7+
## [1.9.1]
8+
* [#872](https://github.com/fluttercommunity/chewie/pull/872): feat: Add showSubtitles flag to control subtitles (#648). Thanks [floodoo](https://github.com/floodoo).
9+
* [#890](https://github.com/fluttercommunity/chewie/pull/890): Fix issue 888. Thanks [diegotori](https://github.com/diegotori).
10+
* **IMPORTANT**: Relaxed the minimum supported Flutter version to `3.24`.
11+
From now on, this library will make a best effort to support the latest `N-1` Flutter version at the minimum.
12+
13+
## [1.9.0]
14+
* **BREAKING CHANGE**: Library now requires at least Flutter version `3.27.0`.
15+
16+
## [1.8.7]
17+
* ⬆️ [#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).
18+
19+
## [1.8.6]
20+
* ⬆️ [#874](https://github.com/fluttercommunity/chewie/pull/874): Add `devtools_options.yaml` configuration files. Thanks [MoRmdn](https://github.com/MoRmdn).
21+
122
## [1.8.5]
223
* ⬆️ [#703](https://github.com/fluttercommunity/chewie/pull/703): Adding Seek buttons for Android. Thanks [GyanendroKh](https://github.com/GyanendroKh).
324
* 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: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,53 @@
88

99
The video player for Flutter with a heart of gold.
1010

11-
The [`video_player`](https://pub.dartlang.org/packages/video_player) plugin provides low-level access to video playback. Chewie uses the `video_player` under the hood and wraps it in a friendly Material or Cupertino UI!
11+
The [`video_player`](https://pub.dartlang.org/packages/video_player) plugin provides low-level
12+
access to video playback.
1213

13-
## Preview
14+
Chewie uses the `video_player` under the hood and wraps it in a friendly Material or Cupertino UI!
1415

15-
| MaterialControls | MaterialDesktopControls |
16-
| :--------------: | :---------------------: |
17-
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |
16+
## Table of Contents
17+
1. 🚨 [IMPORTANT!!! (READ THIS FIRST)](#-important-read-this-first)
18+
2. 🔀 [Flutter Version Compatibility](#-flutter-version-compatibility)
19+
3. 🖼️ [Preview](#%EF%B8%8F-preview)
20+
4. ⬇️ [Installation](#%EF%B8%8F-installation)
21+
5. 🕹️ [Using it](#%EF%B8%8F-using-it)
22+
6. ⚙️ [Options](#%EF%B8%8F-options)
23+
7. 🔡 [Subtitles](#-subtitles)
24+
8. 🧪 [Example](#-example)
25+
9.[Migrating from Chewie < 0.9.0](#-migrating-from-chewie--090)
26+
10. 🗺️ [Roadmap](#%EF%B8%8F-roadmap)
27+
11. 📱 [iOS warning](#-ios-warning-)
28+
29+
30+
## 🚨 IMPORTANT!!! (READ THIS FIRST)
31+
This library is __NOT__ responsible for any issues caused by `video_player`, since it's merely a UI
32+
layer on top of it.
33+
34+
In other words, if you see any `PlatformException`s being thrown in your app due to video playback,
35+
they are exclusive to the `video_player` library.
36+
37+
Instead, please raise an issue related to it with the [Flutter Team](https://github.com/flutter/flutter/issues/new/choose).
38+
39+
## 🔀 Flutter Version Compatibility
40+
41+
This library will at the very least make a solid effort to support the second most recent version
42+
of Flutter released. In other words, it will adopt `N-1` version support at
43+
the bare minimum.
44+
45+
However, this cannot be guaranteed due to major changes between Flutter versions. Should that occur,
46+
future updates will be released as major or minor versions as needed.
47+
48+
## 🖼️ Preview
49+
50+
| MaterialControls | MaterialDesktopControls |
51+
|:-------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------:|
52+
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |
1853

1954
### CupertinoControls
2055
![](https://github.com/brianegan/chewie/raw/master/assets/CupertinoControls.png)
2156

22-
## Installation
57+
## ⬇️ Installation
2358

2459
In your `pubspec.yaml` file within your Flutter Project add `chewie` and `video_player` under dependencies:
2560

@@ -29,10 +64,12 @@ dependencies:
2964
video_player: <latest_version>
3065
```
3166
32-
## Using it
67+
## 🕹️ Using it
3368
3469
```dart
3570
import 'package:chewie/chewie.dart';
71+
import 'package:video_player/video_player.dart';
72+
3673
final videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(
3774
'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4'));
3875

@@ -59,7 +96,7 @@ void dispose() {
5996
}
6097
```
6198

62-
## Options
99+
## ⚙️ Options
63100

64101
![](https://github.com/brianegan/chewie/raw/master/assets/Options.png)
65102

@@ -125,13 +162,19 @@ optionsTranslation: OptionsTranslation(
125162
),
126163
```
127164

128-
## Subtitles
165+
## 🔡 Subtitles
166+
167+
> Since version 1.1.0, Chewie supports subtitles.
168+
169+
Chewie allows you to enhance the video playback experience with text overlays. You can add a `List<Subtitle>` to your `ChewieController` and fully customize their appearance using the `subtitleBuilder` function.
170+
171+
### Showing Subtitles by Default
129172

130-
> Since version 1.1.0 chewie supports subtitles. Here you can see how to use them.
173+
Chewie provides the `showSubtitles` flag, allowing you to control whether subtitles are displayed automatically when the video starts. By default, this flag is set to `false`.
131174

132-
You can provide an `List<Subtitle>` and customize your subtitles with the `subtitleBuilder` function.
175+
### Adding Subtitles
133176

134-
Add subtitles to your `ChewieController` like the following example:
177+
Here’s an example of how to add subtitles to your `ChewieController`:
135178

136179
```dart
137180
ChewieController(
@@ -149,9 +192,10 @@ ChewieController(
149192
index: 1,
150193
start: const Duration(seconds: 10),
151194
end: const Duration(seconds: 20),
152-
text: 'Whats up? :)',
195+
text: 'What’s up? :)',
153196
),
154197
]),
198+
showSubtitles: true, // Automatically display subtitles
155199
subtitleBuilder: (context, subtitle) => Container(
156200
padding: const EdgeInsets.all(10.0),
157201
child: Text(
@@ -162,9 +206,16 @@ ChewieController(
162206
);
163207
```
164208

165-
The `index` attribute is for if you want to structure your subtitles in your database and provide your indexes here. `end` and `text` are the key attributes.
209+
### Subtitle Structure
166210

167-
The Duration defines which part of your video your subtitles should start and end. For example, if your video is 10 minutes long and you want to add a subtitle between: `00:00` and `00:10`'th of a second:
211+
The `Subtitle` model contains the following key attributes:
212+
213+
- **`index`**: A unique identifier for the subtitle, useful for database integration.
214+
- **`start`**: The starting point of the subtitle, defined as a `Duration`.
215+
- **`end`**: The ending point of the subtitle, defined as a `Duration`.
216+
- **`text`**: The subtitle text that will be displayed.
217+
218+
For example, if your video is 10 minutes long and you want to add a subtitle that appears between `00:00` and `00:10`, you can define it like this:
168219

169220
```dart
170221
Subtitle(
@@ -175,11 +226,15 @@ Subtitle(
175226
),
176227
```
177228

178-
## Example
229+
### Customizing Subtitles
230+
231+
Use the `subtitleBuilder` function to customize how subtitles are rendered, allowing you to modify text styles, add padding, or apply other customizations to your subtitles.
232+
233+
## 🧪 Example
179234

180235
Please run the app in the [`example/`](https://github.com/brianegan/chewie/tree/master/example) folder to start playing!
181236

182-
## Migrating from Chewie < 0.9.0
237+
## Migrating from Chewie < 0.9.0
183238

184239
Instead of passing the `VideoPlayerController` and your options to the `Chewie` widget you now pass them to the `ChewieController` and pass that later to the `Chewie` widget.
185240

@@ -205,7 +260,7 @@ final playerWidget = Chewie(
205260
);
206261
```
207262

208-
## Roadmap
263+
## 🗺️ Roadmap
209264

210265
- [x] MaterialUI
211266
- [x] MaterialDesktopUI
@@ -231,7 +286,7 @@ final playerWidget = Chewie(
231286
- [ ] Screen-Mirroring / Casting (Google Chromecast)
232287

233288

234-
## iOS warning
289+
## 📱 iOS warning
235290

236291
The video_player plugin used by chewie will only work in iOS simulators if you are on flutter 1.26.0 or above. You may need to switch to the beta channel `flutter channel beta`
237292
Please refer to this [issue](https://github.com/flutter/flutter/issues/14647).

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,

example/lib/app/app.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class _ChewieDemoState extends State<ChewieDemo> {
4141
}
4242

4343
List<String> srcs = [
44-
"https://assets.mixkit.co/videos/preview/mixkit-spinning-around-the-earth-29351-large.mp4",
45-
"https://assets.mixkit.co/videos/preview/mixkit-daytime-city-traffic-aerial-view-56-large.mp4",
46-
"https://assets.mixkit.co/videos/preview/mixkit-a-girl-blowing-a-bubble-gum-at-an-amusement-park-1226-large.mp4"
44+
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
45+
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
46+
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
4747
];
4848

4949
Future<void> initializePlayer() async {
@@ -126,6 +126,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
126126
];
127127
},
128128
subtitle: Subtitles(subtitles),
129+
showSubtitles: true,
129130
subtitleBuilder: (context, dynamic subtitle) => Container(
130131
padding: const EdgeInsets.all(10.0),
131132
child: subtitle is InlineSpan

lib/src/chewie_player.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ class ChewieController extends ChangeNotifier {
288288
this.zoomAndPan = false,
289289
this.maxScale = 2.5,
290290
this.subtitle,
291+
this.showSubtitles = false,
291292
this.subtitleBuilder,
292293
this.customControls,
293294
this.errorBuilder,
@@ -339,6 +340,7 @@ class ChewieController extends ChangeNotifier {
339340
bool? zoomAndPan,
340341
double? maxScale,
341342
Subtitles? subtitle,
343+
bool? showSubtitles,
342344
Widget Function(BuildContext, dynamic)? subtitleBuilder,
343345
Widget? customControls,
344346
WidgetBuilder? bufferingBuilder,
@@ -391,6 +393,7 @@ class ChewieController extends ChangeNotifier {
391393
optionsBuilder: optionsBuilder ?? this.optionsBuilder,
392394
additionalOptions: additionalOptions ?? this.additionalOptions,
393395
showControls: showControls ?? this.showControls,
396+
showSubtitles: showSubtitles ?? this.showSubtitles,
394397
subtitle: subtitle ?? this.subtitle,
395398
subtitleBuilder: subtitleBuilder ?? this.subtitleBuilder,
396399
customControls: customControls ?? this.customControls,
@@ -454,6 +457,12 @@ class ChewieController extends ChangeNotifier {
454457
/// Add a List of Subtitles here in `Subtitles.subtitle`
455458
Subtitles? subtitle;
456459

460+
/// Determines whether subtitles should be shown by default when the video starts.
461+
///
462+
/// If set to `true`, subtitles will be displayed automatically when the video
463+
/// begins playing. If set to `false`, subtitles will be hidden by default.
464+
bool showSubtitles;
465+
457466
/// The controller for the video you want to play
458467
final VideoPlayerController videoPlayerController;
459468

lib/src/cupertino/cupertino_controls.dart

Lines changed: 3 additions & 2 deletions
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),
@@ -641,7 +641,8 @@ class _CupertinoControlsState extends State<CupertinoControls>
641641
}
642642

643643
Future<void> _initialize() async {
644-
_subtitleOn = chewieController.subtitle?.isNotEmpty ?? false;
644+
chewieController.showSubtitles &&
645+
(chewieController.subtitle?.isNotEmpty ?? false);
645646
controller.addListener(_updateState);
646647

647648
_updateState();

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
}

0 commit comments

Comments
 (0)