chewie
chewie copied to clipboard
How to check Player start playing video?
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?
@aipxperts-developer did you find any solution to this?
@aipxperts-developer
_controller!.value.isPlaying