Skip to content

[Fixed] Seeking after video play finished causes inconsistent player state. #252

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Changelog

## 0.9.8+1
* Require latest flutter stable version

## 0.9.8

* Hero Widget is no longer used (thanks @localpcguy)
Expand Down
180 changes: 90 additions & 90 deletions example/android/gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
8 changes: 8 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/rashedoz/softwares/Softs/flutter"
export "FLUTTER_APPLICATION_PATH=/Volumes/rashed_personal/FLutter_Core_Dev/CustomChewie/chewie/example"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/rashedoz/softwares/Softs/flutter/bin/cache/artifacts/engine/ios"
7 changes: 6 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ description: An example of how to use the chewie for Flutter
dependencies:
chewie:
path: ../
video_player: ^0.10.0+2
# video_player: ^0.10.0+2
video_player:
git:
url: https://github.com/rashedoz/plugins.git
path: packages/video_player

auto_orientation: ^0.0.2
flutter:
sdk: flutter
Expand Down
27 changes: 20 additions & 7 deletions lib/src/material_progress_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import 'package:video_player/video_player.dart';

class MaterialVideoProgressBar extends StatefulWidget {
MaterialVideoProgressBar(
this.controller, {
ChewieProgressColors colors,
this.onDragEnd,
this.onDragStart,
this.onDragUpdate,
}) : colors = colors ?? ChewieProgressColors();
this.controller, {
ChewieProgressColors colors,
this.onDragEnd,
this.onDragStart,
this.onDragUpdate,
}) : colors = colors ?? ChewieProgressColors();

final VideoPlayerController controller;
final ChewieProgressColors colors;
Expand Down Expand Up @@ -99,6 +99,12 @@ class _VideoProgressBarState extends State<MaterialVideoProgressBar> {
if (_controllerWasPlaying) {
controller.play();
}
/// Seek playes video without resuming the controls to play state
/// Check if seeked from video end then play video controller
if(controller.value.position == controller.value.duration){
controller.pause();
}
////////

if (widget.onDragEnd != null) {
widget.onDragEnd();
Expand All @@ -108,6 +114,13 @@ class _VideoProgressBarState extends State<MaterialVideoProgressBar> {
if (!controller.value.initialized) {
return;
}
/// Seek playes video without resuming the controls to play state
/// Check and play video if the controller is in pause state
if(!controller.value.isPlaying){
controller.play();
}
////////

seekToRelativePosition(details.globalPosition);
},
);
Expand Down Expand Up @@ -145,7 +158,7 @@ class _ProgressBarPainter extends CustomPainter {
final double playedPartPercent =
value.position.inMilliseconds / value.duration.inMilliseconds;
final double playedPart =
playedPartPercent > 1 ? size.width : playedPartPercent * size.width;
playedPartPercent > 1 ? size.width : playedPartPercent * size.width;
for (DurationRange range in value.buffered) {
final double start = range.startFraction(value.duration) * size.width;
final double end = range.endFraction(value.duration) * size.width;
Expand Down
10 changes: 7 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: chewie
description: A video player for Flutter with Cupertino and Material play controls
version: 0.9.8+1
version: 0.9.8
homepage: https://github.com/brianegan/chewie
authors:
- Brian Egan <brian@brianegan.com>
- Ben Hagen <ben@ottomatic.io>

environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
flutter: ">=1.9.1 <2.0.0"

dependencies:
open_iconic_flutter: ">=0.3.0 <0.4.0"
video_player: ">=0.7.0 <0.11.0"
# video_player: ">=0.7.0 <0.11.0"
video_player:
git:
url: https://github.com/rashedoz/plugins.git
path: packages/video_player

screen: ">=0.0.4 <0.1.0"
flutter:
sdk: flutter
Expand Down