I am making a page to show a lot of videos from youtube and am using the ext_video_player in flutter web. But now I want to enable show controls. I also want it to be possible for an app. I saw in this stack over flow post. But the chewie player says that it needs a video controller player from video_player not ext_video_player. Is there any other way to do this so that it works both for flutter web and app and also allows youtube videos. the youtube player plugin is not a choice because of some reasons.I have been unable to make it for even one. Code using rn
class videoBox2 extends StatefulWidget {
String Video;
videoBox2(this.Video);
@override
_videoBox2State createState() => _videoBox2State(Video);
}
class _videoBox2State extends State<videoBox2> {
String Video;
bool error = false;
_videoBox2State(this.Video);
VideoPlayerController _controller;
@override
void dispose(){
super.dispose();
_controller.dispose();
}
@override
void initState(){
super.initState();
_controller = VideoPlayerController.network(
Video,
);
_controller.initialize().then((value) {
setState(() {
});
});
_controller.addListener(() {
if (_controller.value.hasError) {
setState(() {
error = true;
print(Video);
});
}
});
}
@override
Widget build(BuildContext context) {
return error?Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(15))
),
child: Image(fit:BoxFit.cover,image:NetworkImage("https://hiapseng-thailand.com/wp-content/themes/skywalker/facilities/video-placeholder.jpg"))
):GestureDetector(
onTap:(){
_controller.value.isPlaying?
_controller.pause()
:_controller.play();
},
child: Container(
width:MediaQuery.of(context).size.width*0.7,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(15))
),
child: VideoPlayer(_controller),
)
);
}
}