Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The video player value.isBuffering always return true after seekTo any position #165149

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
PachecoLpG opened this issue Mar 13, 2025 · 19 comments
Labels
found in release: 3.29 Found to occur in 3.29 found in release: 3.30 Found to occur in 3.30 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: video_player The Video Player plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team

Comments

@PachecoLpG
Copy link

Steps to reproduce

Start the video and seekTo any position

Expected results

isBuffering should return false after buffering

Actual results

isBuffering remains true for the entire duration of the video and the video continues to play

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() => runApp(const VideoApp());

/// Stateful widget to fetch and then display video content.
class VideoApp extends StatefulWidget {
  const VideoApp({super.key});

  @override
  _VideoAppState createState() => _VideoAppState();
}

class _VideoAppState extends State<VideoApp> {
  late VideoPlayerController _controller;
  

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.networkUrl(Uri.parse(
        "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"))
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });

    _controller.addListener(printBuffer);
  }

  void printBuffer() => print(_controller.value.isBuffering);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        body: Builder(builder: (context) {
          return _controller.value.isInitialized
              ? Stack(
                  alignment: Alignment.center,
                  children: <Widget>[
                    AspectRatio(
                      aspectRatio: _controller.value.aspectRatio,
                      child: VideoPlayer(_controller),
                    ),
                    if (_controller.value.isBuffering)
                      Center(child: CircularProgressIndicator()),
                  ],
                )
              : const Center(child: CircularProgressIndicator());
        }),
        floatingActionButton: Column(
          mainAxisSize: MainAxisSize.min,
          spacing: 16,
          children: <Widget>[
            FloatingActionButton(
              onPressed: () async {
                Duration? pos = await _controller.position;
                if (pos == null) {
                  return;
                }
                setState(() {
                  _controller.seekTo(pos + Duration(seconds: 10));
                });
              },
              child: Text('Skip 10s'),
            ),
            FloatingActionButton(
              onPressed: () {
                setState(() {
                  _controller.value.isPlaying
                      ? _controller.pause()
                      : _controller.play();
                });
              },
              child: Icon(
                _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.1, on Ubuntu 24.04.2 LTS 6.8.0-55-generic, locale pt_BR.UTF-8) [382ms]
    • Flutter version 3.29.1 on channel stable at /home/lucas/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 09de023485 (13 days ago), 2025-02-28 13:44:05 -0800
    • Engine revision 871f65ac1b
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [4,2s]
    • Android SDK at /home/lucas/Android/Sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /home/lucas/android-studio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[✓] Android Studio (version 2024.2) [228ms]
    • Android Studio at /home/lucas/android-studio
    • Flutter plugin version 83.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[✓] VS Code (version 1.98.0) [23ms]
    • VS Code at /usr/share/code
    • Flutter extension version 3.106.0

[✓] Connected device (1 available) [243ms]
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)

[✓] Network resources [1.176ms]
    • All expected network resources are available.
@danagbemava-nc
Copy link
Member

danagbemava-nc commented Mar 14, 2025

Reproducible using the code sample provided above. This appears to work fine on iOS but not on android. See the recordings below

Notice that on android, once the skip button is tapped, the buffering never stops.

Tested with video_player: ^2.9.3

android iOS
Screen.Recording.2025-03-14.at.7.19.20.AM.mov
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-03-14.at.07.21.59.mp4
flutter doctor -v
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.1 24D70 darwin-arm64, locale en-US) [2.4s]
    • Flutter version 3.29.2 on channel stable at /Users/deanli/dev/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c236373904 (11 hours ago), 2025-03-13 16:17:06 -0400
    • Engine revision 18b71d647a
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [3.0s]
    • Android SDK at /Users/deanli/Library/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /Users/deanli/Applications/Android Studio Meerkat 2024.3.1 RC 2.app/Contents/jbr/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [2.2s]
    • Xcode at /Applications/Xcode-16.3.0-Beta.2.app/Contents/Developer
    • Build 16E5121h
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [16ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [15ms]
    • Android Studio at /Users/deanli/Applications/Android Studio Meerkat 2024.3.1 RC 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Users/deanli/Applications/Android Studio Meerkat 2024.3.1 RC 2.app
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] Android Studio (version 2024.2) [13ms]
    • Android Studio at /Users/deanli/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.98.2) [13ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.106.0

[✓] Connected device (5 available) [8.3s]
    • Dean’s iPad (wireless) (mobile) • 00008103-000825C811E3401E            • ios            • iOS 18.3.1 22D72
    • iPhone 16 Pro (mobile)          • B0797AD6-E1FD-4B41-A022-2D7E2276C29B • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.3.1 24D70 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.3.1 24D70 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 134.0.6998.89
    ! Error: Browsing on the local area network for Nexus. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [1,162ms]
    • All expected network resources are available.

• No issues found!
[!] Flutter (Channel master, 3.30.0-1.0.pre.603, on macOS 15.3.1 24D70 darwin-arm64, locale en-US) [5.4s]
    • Flutter version 3.30.0-1.0.pre.603 on channel master at /Users/deanli/dev/master
    ! Warning: `flutter` on your path resolves to /Users/deanli/dev/stable/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/deanli/dev/stable/bin/dart, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d64db52438 (6 hours ago), 2025-03-13 18:27:29 -0700
    • Engine revision d64db52438
    • Dart version 3.8.0 (build 3.8.0-188.0.dev)
    • DevTools version 2.45.0-dev.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [3.5s]
    • Android SDK at /Users/deanli/Library/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /Users/deanli/Applications/Android Studio Meerkat 2024.3.1 RC 2.app/Contents/jbr/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [2.3s]
    • Xcode at /Applications/Xcode-16.3.0-Beta.2.app/Contents/Developer
    • Build 16E5121h
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [19ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [18ms]
    • Android Studio at /Users/deanli/Applications/Android Studio Meerkat 2024.3.1 RC 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Users/deanli/Applications/Android Studio Meerkat 2024.3.1 RC 2.app
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] Android Studio (version 2024.2) [15ms]
    • Android Studio at /Users/deanli/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.98.2) [15ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.106.0

[✓] Connected device (4 available) [8.5s]
    • Dean’s iPad (wireless) (mobile) • 00008103-000825C811E3401E            • ios            • iOS 18.3.1 22D72
    • iPhone 16 Pro (mobile)          • B0797AD6-E1FD-4B41-A022-2D7E2276C29B • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.3.1 24D70 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 134.0.6998.89
    ! Error: Browsing on the local area network for Nexus. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [1,061ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

@danagbemava-nc danagbemava-nc added platform-android Android applications specifically p: video_player The Video Player plugin package flutter/packages repository. See also p: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-android Owned by Android platform team fyi-ecosystem For the attention of Ecosystem team found in release: 3.29 Found to occur in 3.29 found in release: 3.30 Found to occur in 3.30 and removed in triage Presently being triaged by the triage team labels Mar 14, 2025
@percy54321

This comment has been minimized.

@reidbaker reidbaker added triaged-android Triaged by Android platform team P2 Important issues not at the top of the work list labels Mar 18, 2025
@stuartmorgan-g
Copy link
Contributor

We recently had to disable a test in flutter/packages CI because of this; the test was waiting for buffering to report stopped, and never was. This was an out-of-band failure whose cause we were not able to determine. Our only guess was that this changed in ExoPlayer, but we couldn't see any obvious reason that the ExoPlayer version would have changed out of band (since Gradle deps don't automatically pull the latest, unlike unpinned pub deps).

@stuartmorgan-g stuartmorgan-g added the triaged-ecosystem Triaged by Ecosystem team label Mar 18, 2025
@flutter-triage-bot flutter-triage-bot bot removed fyi-ecosystem For the attention of Ecosystem team triaged-ecosystem Triaged by Ecosystem team labels Mar 18, 2025
@bailyzheng

This comment has been minimized.

@ddtv368

This comment has been minimized.

@wangya123456789

This comment has been minimized.

@wenwangwill
Copy link

If you want to temporarily solve this problem, you can compare the current playback position with the buffer position to determine whether it is in the buffer.

      controller.addListener(() {
        final value = controller.value;
        final buffer = value.buffered.lastOrNull?.end.inMilliseconds;
        final position = value.position.inMilliseconds;
        bool buffering = position == buffer;
      });

@timoxd7
Copy link

timoxd7 commented Apr 2, 2025

@wenwangwill Thanks for the workaround. This indeed works, however if seekTo a previous position while having the video paused, this might give a true on buffering even though it is not buffering nor playing. But as workaround for now, this seems good.

@xshiwei
Copy link

xshiwei commented Apr 2, 2025

I still hope it can be solved as soon as possible, this problem is quite serious

@AnalabaSylvester
Copy link

this is a realy serious issues, and really feels worse on live stream where you wont want to track seek position .

@AnalabaSylvester
Copy link

void _updateState() {
if (mounted) {
final newIsPlaying = widget.controller.value.isPlaying;
final newPosition = widget.controller.value.position.inSeconds.toDouble();
final position = widget.controller.value.position;
final buffered = widget.controller.value.buffered;

  // Custom buffering logic: Check if position is outside all buffered ranges
  final newIsBuffering =
      buffered.isEmpty ||
      !buffered.any(
        (range) => position >= range.start && position <= range.end,
      );

  if (_isPlaying != newIsPlaying ||
      _currentPosition != newPosition ||
      _isBuffering != newIsBuffering) {
    setState(() {
      _isPlaying = newIsPlaying;
      _currentPosition = newPosition;
      _isBuffering = newIsBuffering;
      if (_isBuffering && _isVisible) {
        _isVisible = false; // Hide controls if buffering starts
        _hideTimer?.cancel(); // Cancel hide timer if active
      }
    });
  }

  // Debug logging
  log(
    "Position: $position, Buffered: ${buffered.map((r) => '[${r.start}-${r.end}]').join(', ')}",
  );
  log(
    "Custom Buffering: $_isBuffering, Official: ${widget.controller.value.isBuffering}",
  );
}

} . this walk around helps a little tho but did not fully meet my requirement .

@Tangxiaochuanle

This comment has been minimized.

@Tangxiaochuanle

This comment has been minimized.

@ihijazi

This comment has been minimized.

1 similar comment
@QinweiD

This comment has been minimized.

@xshiwei
Copy link

xshiwei commented Apr 16, 2025

Limit video_player_android to version 2.7.17, do not upgrade!

@neo-etremblay
Copy link

I also have this issue with video_player_android 2.8.2

@iammofidul
Copy link

iammofidul commented Apr 24, 2025

bool isActuallyBuffering = controller.value.isBuffering; if (controller.value.isPlaying && controller.value.position.inMilliseconds > 0 && controller.value.isBuffering) { isActuallyBuffering = false; }

Until they fixed it we can use above workaround

@harry-odinson-369

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
found in release: 3.29 Found to occur in 3.29 found in release: 3.30 Found to occur in 3.30 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: video_player The Video Player plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team
Projects
None yet
Development

No branches or pull requests