Closed Claudiatp22 closed 3 years ago
Hi @Claudiatp22, thanks for filing the issue, I can confirm the video restarts on scrubbing the progress bar to the end as of video_player: 2.2.6
on all video_player supported platforms (iOS, Android, web)
to avoid the video restarting by itself
To make sure I'm understanding correctly: is the behavior that if the video is playing, and is scrubbed to the end, it automatically jumps to the beginning and continues playing?
If so, that's just a bug; the intent of the change was to change the behavior of explicitly starting playback when the video is at the end.
To make sure I'm understanding correctly: is the behavior that if the video is playing, and is scrubbed to the end, it automatically jumps to the beginning and continues playing?
Yes, if the video is manually scrubbed to the end it jumps to the beginning.
If so, that's just a bug
Labeling this issue as a bug instead of proposal
@stuartmorgan I'm also facing a similar issue but only on flutter web in android works fine
but this issue occurs only for the first time, after hot restart/reload works fine
Sample video -
when i try to play video from assets in flutter web
NOTE - this issue occurs only for the first time, after hot restart/reload works fine
when i try to play video from this url https://samplelib.com/lib/preview/mp4/sample-10s.mp4 in flutter web
NOTE - this issue occurs only for the first time, after hot restart/reload works fine
To reproduce issue 2
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
Future<void> main() async {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(home: VideoApp());
}
}
class VideoApp extends StatefulWidget {
@override
_VideoAppState createState() => _VideoAppState();
}
class _VideoAppState extends State<VideoApp> {
late VideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.asset(
'https://samplelib.com/lib/preview/mp4/sample-10s.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Demo',
home: Scaffold(
body: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 8),
child: _controller.value.isInitialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
VideoPlayer(_controller),
VideoProgressIndicator(_controller, allowScrubbing: true),
],
),
)
: Container(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}
flutter doctor -v
[✓] Flutter (Channel stable, 2.5.3, on Ubuntu 20.04.3 LTS
5.11.0-38-generic, locale en_GB.UTF-8)
• Flutter version 2.5.3 at /home/dev/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (4 weeks ago), 2021-10-15
10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✓] Android toolchain - develop for Android devices (Android SDK
version 30.0.2)
• Android SDK at /home/dev/Android/Sdk
• Platform android-31, build-tools 30.0.2
• ANDROID_HOME = /home/dev/Android/Sdk
• Java binary at:
/home/dev/Downloads/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[✓] Android Studio (version 4.1)
• Android Studio at /home/dev/Downloads/android-studio
• Flutter plugin version 52.0.1
• Dart plugin version 201.9245
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.61.2)
• VS Code at /usr/share/code
• Flutter extension version 3.28.0
[✓] Connected device (3 available)
• Redmi 6 Pro (mobile) • 48b191740505 • android-arm64 •
Android 9 (API 28)
• Linux (desktop) • linux • linux-x64 •
Ubuntu 20.04.3 LTS 5.11.0-38-generic
• Chrome (web) • chrome • web-javascript •
Google Chrome 95.0.4638.69
• No issues found!
@newtaDev The video you posted is not showing this issue. You should file a new issue for your bug.
@stuartmorgan
Okey. Thanks for responding
I have opened new issue #93486 please check.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.
Use case
After the merge of this PR our application started experiencing some unexpected behaviours when the user dragged the video player position until the end, specifically this new condition in the
play()
method. This was an unexpected change that wasn't reflected in the changelog 😕.Proposal
Since this behaviour is not exposed in any way we made a workaround on our code to avoid the video restarting by itself. However, since this is more like a feature would it be possible to make it optional?