Skip to content

Commit

Permalink
Merge commit '33e95c0b786d245fc1149cddb34141e1a626ce87' into custom-lg
Browse files Browse the repository at this point in the history
* commit '33e95c0b786d245fc1149cddb34141e1a626ce87':
  chewie, version 1.7.5. Addresses fluttercommunity#802 and fluttercommunity#810.
  Add documentation to the play function
  update version and changelog
  Add documentation
  Refactor un needed set states, refactor play if finished( as video player restarts if finished)
  Add fix for returning from full screen web
  Update chewie_player.dart

# Conflicts:
#	lib/src/chewie_player.dart
  • Loading branch information
lg8294 committed Aug 27, 2024
2 parents 126bd35 + 33e95c0 commit f907a45
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .fvm/flutter_sdk
3 changes: 1 addition & 2 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"flutterSdkVersion": "stable",
"flavors": {}
"flutterSdkVersion": "3.19.6"
}
4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.19.6",
"flavors": {}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ build/

.project
.classpath
.settings
.settings

# FVM Version Cache
.fvm/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.7.5
* 🛠️ [#810](https://github.com/fluttercommunity/chewie/pull/810): Fixed : Web full screen issue (#790 #688). Thanks [ToddZeil](https://github.com/ToddZeil).
* 🛠️ [#802](https://github.com/fluttercommunity/chewie/pull/802): Update chewie_player.dart. Thanks [B0yma](https://github.com/B0yma).

## 1.7.4
* 🛠️ [#774](https://github.com/fluttercommunity/chewie/pull/774): Fixed : Playback speed reset on forwarding video. Thanks [Kronos-2701](https://github.com/Kronos-2701).

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -420,7 +420,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -469,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
13 changes: 8 additions & 5 deletions example/ios/Runner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
Expand All @@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="48" y="-2"/>
</scene>
</scenes>
</document>
22 changes: 21 additions & 1 deletion lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:chewie/src/models/options_translation.dart';
import 'package:chewie/src/models/subtitle_model.dart';
import 'package:chewie/src/notifiers/player_notifier.dart';
import 'package:chewie/src/player_with_controls.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -57,6 +58,7 @@ class ChewieState extends State<Chewie> {
void dispose() {
widget.controller.removeListener(listener);
widget.controller.videoPlayerController.removeListener(videoPlayerListener);
notifier.dispose();
super.dispose();
}

Expand Down Expand Up @@ -179,6 +181,11 @@ class ChewieState extends State<Chewie> {
context,
rootNavigator: widget.controller.useRootNavigator,
).push(route);

if (kIsWeb) {
_reInitializeControllers();
}

_isFullScreen = false;
widget.controller.exitFullScreen();

Expand Down Expand Up @@ -245,6 +252,18 @@ class ChewieState extends State<Chewie> {
}
}
}

///When viewing full screen on web, returning from full screen causes original video to lose the picture.
///We re initialise controllers for web only when returning from full screen
void _reInitializeControllers() {
final prevPosition = widget.controller.videoPlayerController.value.position;
widget.controller.videoPlayerController.initialize().then((_) async {
widget.controller._initialize();
widget.controller.videoPlayerController.seekTo(prevPosition);
await widget.controller.videoPlayerController.play();
widget.controller.videoPlayerController.pause();
});
}
}

/// The ChewieController is used to configure and drive the Chewie Player
Expand Down Expand Up @@ -351,7 +370,8 @@ class ChewieController extends ChangeNotifier {
Animation<double>,
Animation<double>,
ChewieControllerProvider,
)? routePageBuilder,
)?
routePageBuilder,
}) {
return ChewieController(
draggableProgressBar: draggableProgressBar ?? this.draggableProgressBar,
Expand Down
47 changes: 23 additions & 24 deletions lib/src/material/material_desktop_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -485,40 +485,39 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
void _onExpandCollapse() {
setState(() {
notifier.hideStuff = true;
});

chewieController.toggleFullScreen();
_showAfterExpandCollapseTimer =
Timer(const Duration(milliseconds: 300), () {
setState(() {
_cancelAndRestartTimer();
});
chewieController.toggleFullScreen();

_showAfterExpandCollapseTimer =
Timer(const Duration(milliseconds: 300), () {
setState(() {
_cancelAndRestartTimer();
});
});
}

void _playPause() {
final isFinished = _latestValue.position >= _latestValue.duration;

setState(() {
if (controller.value.isPlaying) {
if (controller.value.isPlaying) {
setState(() {
notifier.hideStuff = false;
_hideTimer?.cancel();
controller.pause();
} else {
_cancelAndRestartTimer();
});

if (!controller.value.isInitialized) {
controller.initialize().then((_) {
controller.play();
});
} else {
if (isFinished) {
controller.seekTo(Duration.zero);
}
_hideTimer?.cancel();
controller.pause();
} else {
_cancelAndRestartTimer();

if (!controller.value.isInitialized) {
controller.initialize().then((_) {
//[VideoPlayerController.play] If the video is at the end, this method starts playing from the beginning
controller.play();
}
});
} else {
//[VideoPlayerController.play] If the video is at the end, this method starts playing from the beginning
controller.play();
}
});
}
}

void _startHideTimer() {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chewie
description: A video player for Flutter with Cupertino and Material play controls
version: 1.7.4
version: 1.7.5
homepage: http://github.com/fluttercommunity/chewie

environment:
Expand Down

0 comments on commit f907a45

Please sign in to comment.