fluttercommunity / fluttercommunity/chewie
How to check Player start playing video?
- Dominant language
- Dart
- Stars
- 2.1k
- Forks
- 1.1k
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 6
Description
Hi, i need to call 1 api when user video playing starts and for that i add listener to check it but not working as expected. Below is my code.
```
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
widget.url)
..initialize().then((_) {
setState(() {});
});
_controller!.addListener(checkVideo);
}
void checkVideo() {
// Implement your calls inside these conditions' bodies :
if (_controller!.value.position ==
const Duration(seconds: 0, minutes: 0, hours: 0) &&
_controller!.value.isPlaying) {
print('video Started');
}
if (!_controller!.value.isPlaying &&
_controller!.value.isInitialized &&
(_controller!.value.duration == _controller!.value.position)) {
print('video Ended ${_controller!.value.duration}');
}
}
```
But this condition become true multiple times even if video doesn't play started and while buffering.
**if (_controller!.value.position == const Duration(seconds: 0, minutes: 0, hours: 0) && _controller!.value.isPlaying)**
**NOTE:** This issue generate when i press press button without video buffers completely. (Works file it i press play button once video bufferes 100%)
How to check Video start & Stop correctly?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.