Skip to content

The video player value.isBuffering returns true as soon as a video finishes playing on android #170737

@timoxd7

Description

@timoxd7

Steps to reproduce

  1. Start a Video via Network URL
  2. Let the Video finish
  3. The loading spinner will appear, meaning the isBuffering variable got true
  4. After a long wait time, the isBuffering value changes to false

Expected results

If a video finishes, it should not be buffered anymore, so isBuffering should stay false.

Actual results

isBuffering changes to true after the video finishes and stays true for a long time (about a minute).
I think this might be related to a previous issue #165149.

Code sample

Code sample (modified from #165149)
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
  State<VideoApp> createState() => _VideoAppState();
}

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

  bool buffering = false;

  @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('----- BUFFERING: ${_controller.value.isBuffering}');

    setState(() {
      buffering = _controller.value.isBuffering;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        body: Builder(
          builder: (context) {
            return Center(
              child: _controller.value.isInitialized
                  ? Stack(
                      alignment: Alignment.center,
                      children: <Widget>[
                        AspectRatio(
                          aspectRatio: _controller.value.aspectRatio,
                          child: VideoPlayer(_controller),
                        ),
                        if (buffering)
                          Center(child: CircularProgressIndicator()),
                      ],
                    )
                  : const CircularProgressIndicator(),
            );
          },
        ),
        floatingActionButton: Column(
          mainAxisSize: MainAxisSize.min,
          spacing: 16,
          children: <Widget>[
            FloatingActionButton(
              onPressed: () async {
                final Duration end = _controller.value.duration;

                setState(() {
                  _controller.seekTo(end - const Duration(seconds: 5));
                });
              },
              child: const Icon(Icons.skip_next),
            ),
            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

No response

Logs

No response

Flutter Doctor output

Doctor output
[!] Flutter (Channel [user-branch], 3.32.4, on macOS 15.5 24F74 darwin-arm64, locale de-DE) [720ms]
    ! Flutter version 3.32.4 on channel [user-branch] at /Users/***/sdk/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 6fba2447e9 (4 days ago), 2025-06-12 19:03:56 -0700
    • Engine revision 8cd19e509d
    • Dart version 3.8.1
    • DevTools version 2.45.1
    • 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 34.0.0) [1.505ms]
    • Android SDK at /Users/***/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [997ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.1) [12ms]
    • Android Studio at /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 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.101.0) [10ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.112.0

[✓] Connected device (4 available) [6,1s]
    • Pixel 7 Pro (mobile)                • 3B061FDH3S11PS            • android-arm64  • Android 16 (API 36)
    • iPhone von *** (wireless) (mobile) • 00008030-00111CEC1E9B802E • ios            • iOS 18.5 22F76
    • macOS (desktop)                     • macos                     • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)                        • chrome                    • web-javascript • Google Chrome 137.0.7151.104
    ! Error: Browsing on the local area network for iPad von ***. 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 [260ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: regressionIt was better in the past than it is nowe: device-specificOnly manifests on certain devicesfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyteam-androidOwned by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions