Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 888 #890

Merged
merged 10 commits into from
Jan 15, 2025
77 changes: 41 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,51 @@ on:
- '**.md'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-format:
name: Check format using dart format.
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Flutter Action
uses: subosito/flutter-action@v2
- name: Check format
run: dart format . --set-exit-if-changed

lint:
name: Lint
# Does a sanity check that packages at least pass analysis on the N-1
# versions of Flutter stable if the package claims to support that version.
# This is to minimize accidentally making changes that break old versions
# (which we don't commit to supporting, but don't want to actively break)
# without updating the constraints.
lint_and_build:
name: Flutter Version ${{ matrix.flutter-version }} Lint and Build.
runs-on: ubuntu-latest

strategy:
matrix:
flutter-version:
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
# 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.
- "3.24.5"
- "3.x"
steps:
- name: Checkout code
- name: 📚 Git Checkout
uses: actions/checkout@v4
- name: Flutter Action

- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2
- name: Install Package Dependencies
with:
flutter-version: ${{ matrix.flutter-version }}
channel: stable
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

- name: 📦 Install Dependencies
run: flutter packages get
- name: Get dependencies for example
run: flutter pub get
working-directory: example
- name: Lint using flutter analyze
run: flutter analyze .

test:
name: Run tests.
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Flutter Action
uses: subosito/flutter-action@v2
- name: Run flutter test
run: |
flutter pub get
flutter test
- name: ✨ Check Formatting
run: dart format --set-exit-if-changed lib

- name: 🕵️ Analyze
run: flutter analyze lib

- name: 🧪 Run Tests
run: flutter test --no-pub --coverage --test-randomize-ordering-seed random

- name: 📁 Upload coverage to Codecov
uses: codecov/codecov-action@v5
61 changes: 48 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,53 @@

The video player for Flutter with a heart of gold.

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!
The [`video_player`](https://pub.dartlang.org/packages/video_player) plugin provides low-level
access to video playback.

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

| MaterialControls | MaterialDesktopControls |
| :--------------: | :---------------------: |
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |
## Table of Contents
1. 🚨 [IMPORTANT!!! (READ THIS FIRST)](#-important-read-this-first)
2. 🔀 [Flutter Version Compatibility](#-flutter-version-compatibility)
3. 🖼️ [Preview](#-preview)
4. ⬇️ [Installation](#-installation)
5. 🕹️ [Using it](#-using-it)
6. ⚙️ [Options](#-options)
7. 🔡 [Subtitles](#-subtitles)
8. 🧪 [Example](#-example)
9. ⏪ [Migrating from Chewie < 0.9.0](#-migrating-from-chewie--090)
10. 🗺️ [Roadmap](#-roadmap)
11. 📱 [iOS warning](#-ios-warning-)


## 🚨 IMPORTANT!!! (READ THIS FIRST)
This library is __NOT__ responsible for any issues caused by `video_player`, since it's merely a UI
layer on top of it.

In other words, if you see any `PlatformException`s being thrown in your app due to video playback,
they are exclusive to the `video_player` library.

Instead, please raise an issue related to it with the [Flutter Team](https://github.com/flutter/flutter/issues/new/choose).

## 🔀 Flutter Version Compatibility

This library will at the very least make a solid effort to support the second most recent version
of Flutter released. In other words, it will adopt `N-1` version support at
the bare minimum.

However, this cannot be guaranteed due to major changes between Flutter versions. Should that occur,
future updates will be released as major or minor versions as needed.

## 🖼️ Preview

| MaterialControls | MaterialDesktopControls |
|:-------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------:|
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |

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

## Installation
## ⬇️ Installation

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

Expand All @@ -29,7 +64,7 @@ dependencies:
video_player: <latest_version>
```

## Using it
## 🕹️ Using it

```dart
import 'package:chewie/chewie.dart';
Expand Down Expand Up @@ -61,7 +96,7 @@ void dispose() {
}
```

## Options
## ⚙️ Options

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

Expand Down Expand Up @@ -127,7 +162,7 @@ optionsTranslation: OptionsTranslation(
),
```

## Subtitles
## 🔡 Subtitles

> Since version 1.1.0, Chewie supports subtitles.

Expand Down Expand Up @@ -195,11 +230,11 @@ Subtitle(

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.

## Example
## 🧪 Example

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

## Migrating from Chewie < 0.9.0
## Migrating from Chewie < 0.9.0

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.

Expand All @@ -225,7 +260,7 @@ final playerWidget = Chewie(
);
```

## Roadmap
## 🗺️ Roadmap

- [x] MaterialUI
- [x] MaterialDesktopUI
Expand All @@ -251,7 +286,7 @@ final playerWidget = Chewie(
- [ ] Screen-Mirroring / Casting (Google Chromecast)


## iOS warning
## 📱 iOS warning

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`
Please refer to this [issue](https://github.com/flutter/flutter/issues/14647).
Expand Down
30 changes: 30 additions & 0 deletions lib/src/material/color_compat_extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

//ignore_for_file: deprecated_member_use
extension ColorCompatExtensions on Color {
/// Returns a new color that matches this color with the given opacity.
///
/// This is a compatibility layer that ensures compatibility with Flutter
/// versions below 3.27. In Flutter 3.27 and later, `Color.withOpacity`
/// has been deprecated in favor of `Color.withValues`.
///
/// This method bridges the gap by providing a consistent way to adjust
/// the opacity of a color across different Flutter versions.
///
/// **Important:** Once the minimum supported Flutter version is bumped
/// to 3.27 or higher, this method should be removed and replaced with
/// `withValues(alpha: opacity)`.
///
/// See also:
/// * [Color.withOpacity], which is deprecated in Flutter 3.27 and later.
/// * [Color.withValues], the recommended replacement for `withOpacity`.
Color withOpacityCompat(double opacity) {
// Compatibility layer that uses the legacy withOpacity method, while
// ignoring the deprecation for now (in order to guarantee N-1 minimum
// version compatibility).
// Once it's removed from a future update, we'll have to replace uses of
// this method with withValues(alpha: opacity).
// TODO: Replace this bridge method once the above holds true.
return withOpacity(opacity);
}
}
7 changes: 4 additions & 3 deletions lib/src/material/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:chewie/src/center_seek_button.dart';
import 'package:chewie/src/chewie_player.dart';
import 'package:chewie/src/chewie_progress_colors.dart';
import 'package:chewie/src/helpers/utils.dart';
import 'package:chewie/src/material/color_compat_extensions.dart';
import 'package:chewie/src/material/material_progress_bar.dart';
import 'package:chewie/src/material/widgets/options_dialog.dart';
import 'package:chewie/src/material/widgets/playback_speed_dialog.dart';
Expand Down Expand Up @@ -470,7 +471,7 @@ class _MaterialControlsState extends State<MaterialControls>
text: '/ ${formatDuration(duration)}',
style: TextStyle(
fontSize: 14.0,
color: Colors.white.withValues(alpha: .75),
color: Colors.white.withOpacityCompat(.75),
fontWeight: FontWeight.normal,
),
)
Expand Down Expand Up @@ -683,9 +684,9 @@ class _MaterialControlsState extends State<MaterialControls>
playedColor: Theme.of(context).colorScheme.secondary,
handleColor: Theme.of(context).colorScheme.secondary,
bufferedColor:
Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
Theme.of(context).colorScheme.surface.withOpacityCompat(0.5),
backgroundColor:
Theme.of(context).disabledColor.withValues(alpha: .5),
Theme.of(context).disabledColor.withOpacityCompat(.5),
),
draggableProgressBar: chewieController.draggableProgressBar,
),
Expand Down
5 changes: 3 additions & 2 deletions lib/src/material/material_desktop_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:chewie/src/center_play_button.dart';
import 'package:chewie/src/chewie_player.dart';
import 'package:chewie/src/chewie_progress_colors.dart';
import 'package:chewie/src/helpers/utils.dart';
import 'package:chewie/src/material/color_compat_extensions.dart';
import 'package:chewie/src/material/material_progress_bar.dart';
import 'package:chewie/src/material/widgets/options_dialog.dart';
import 'package:chewie/src/material/widgets/playback_speed_dialog.dart';
Expand Down Expand Up @@ -649,9 +650,9 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
playedColor: Theme.of(context).colorScheme.secondary,
handleColor: Theme.of(context).colorScheme.secondary,
bufferedColor:
Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
Theme.of(context).colorScheme.surface.withOpacityCompat(0.5),
backgroundColor:
Theme.of(context).disabledColor.withValues(alpha: 0.5),
Theme.of(context).disabledColor.withOpacityCompat(0.5),
),
draggableProgressBar: chewieController.draggableProgressBar,
),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 1.9.0
homepage: https://github.com/fluttercommunity/chewie

environment:
sdk: '>=3.3.0 <4.0.0'
flutter: ">=3.27.0"
sdk: '>=3.5.0 <4.0.0'
flutter: ">=3.24.0"

dependencies:
cupertino_icons: ^1.0.5
Expand Down
Loading