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

@PachecoLpG

Description

@PachecoLpG

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30has 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 specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions