Created
December 2, 2020 09:35
-
-
Save littleironical/258f1ce9c1ebbb5a7a3dc1dd8b04b604 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Have to define the _controller inside initState() to make it work properly. | |
//Inside StateFulClass: | |
YoutubePlayerController _controller; | |
@override | |
void initState() { | |
_controller = YoutubePlayerController( | |
initialVideoId: | |
YoutubePlayer.convertUrlToId(widget.videoLink), | |
flags: YoutubePlayerFlags( | |
mute: false, | |
autoPlay: true, | |
disableDragSeek: true, | |
loop: false, | |
enableCaption: false), | |
); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: YoutubePlayer( | |
controller: _controller, | |
showVideoProgressIndicator: true, | |
bottomActions: <Widget>[ | |
const SizedBox(width: 14.0), | |
CurrentPosition(), | |
const SizedBox(width: 8.0), | |
ProgressBar(isExpanded: true), | |
RemainingDuration(), | |
], | |
aspectRatio: 4 / 3, | |
progressIndicatorColor: Colors.white, | |
onReady: () { | |
print('Player is ready.'); | |
}, | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment