I am using the video_player package provided by flutter team to implement a video player in my flutter project. Everything is working fine when internet is connected. But the problem with me is I could not get the error while turning off my internet and also when I am providing wrong video url to the video player controller. Below is my code:-
videoPlayerController = VideoPlayerController.network(alertClipList[0]);
videoPlayerController.addListener(() {
print('here');
if(videoPlayerController.value.isBuffering){
print('buffering');
}else if(videoPlayerController.value.hasError){
print('error');
}else if(videoPlayerController.value.position == videoPlayerController.value.duration){
print('completed');
}
});
var temp = await videoPlayerController.initialize().then((value){
print('started');
if(videoPlayerController.value.isPlaying){
print('already playing');
return;
}
videoPlayerController.play();
}, onError: (error){
print(error);
print('error is here');
});
And here is the simple UI code:
Widget JVideoPlayer() {
return AspectRatio(
aspectRatio: 16 / 9,
child: VideoPlayer(alertClipController.videoPlayerController));
}
Also I using the below implementation of exoplayer
implementation 'com.google.android.exoplayer:exoplayer:2.16.1'
I solved the issue by removing this line from my app level build.gradle file - implementation 'com.google.android.exoplayer:exoplayer:2.16.1'. I think there is no problem with the video player package, the problem is with the exoplayer.