Closed
Description
Steps to reproduce:
- Let a video finish playing
- call
VideoPlayerController.seekTo()
to some time < the video's duration
Expected result:
Video seeks to correct time and A) remains paused OR B) starts playing and sends periodic VideoPlayerValue
updates
Actual result:
Video seeks to correct time and is seemingly paused BUT the video continues to play (once it buffers) while VideoPlayerController.value.position
does not change and VideoPlayerController.value.isPlaying
stays false.
Device used:
Pixel 3 XL Android 11
Code demo used to reproduce (modified example from README with fast forward/rewind buttons + live play time)
import 'package:video_player/video_player.dart';
import 'package:flutter/material.dart';
void main() => runApp(VideoApp());
class VideoApp extends StatefulWidget {
@override
_VideoAppState createState() => _VideoAppState();
}
class _VideoAppState extends State<VideoApp> {
VideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
})
..addListener(() {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Demo',
home: Scaffold(
body: Center(
child: _controller.value.isInitialized
? Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
),
Text(
'${_controller.value.position}/${_controller.value.duration}'),
],
)
: Container(),
),
floatingActionButton: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FloatingActionButton(
onPressed: () {
setState(() {
_controller.seekTo(
_controller.value.position - Duration(seconds: 5));
});
},
child: Icon(
Icons.fast_rewind,
),
),
FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
FloatingActionButton(
onPressed: () {
setState(() {
_controller.seekTo(_controller.value.duration);
});
},
child: Icon(
Icons.skip_next,
),
),
],
),
),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}