Using the youtube_player_ iframe library I was able to capture some video status data (playing, paused, with/without audio) for xAPI statemetns, but from external buttons, not from the player itself.
Video player
My custom buttons
The clasws builder
However I have not been able to get it to capture the data from the internal controls of the player. I would be very grateful for your help :" )
Video player
Code:
Widget oneVideo(BuildContext context, double heigth, double width) {
return SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: heigth,
width: width,
child: YoutubePlayer(
controller: _controller,
backgroundColor: Colors.black,
),
),
],
));
}
Code:
Row optionButtons(BuildContext context) {
return Row(
children: [
YoutubeValueBuilder(
builder: (context, value) {
return IconButton(
icon: Icon(
value.playerState == PlayerState.playing
? Icons.pause
: Icons.play_arrow,
),
onPressed: () {
if (value.playerState == PlayerState.playing) {
context.ytController.pauseVideo();
pausePlay(
"Pause", "WatchTemplateVideo", context.ytController);
} else {
context.ytController.playVideo();
pausePlay("Play", "WatchTemplateVideo", context.ytController);
}
},
);
},
)
],
);
}
Code:
Widget build(BuildContext context) {
double heigth = MediaQuery.of(context).size.height * 0.7;
double width = MediaQuery.of(context).size.width * 0.7;
return YoutubePlayerScaffold(
controller: _controller,
builder: (context, player) {
return YoutubePlayerControllerProvider(
controller: _controller,
child: Column(
children: [
oneVideo(context, heigth, width),
optionButtons(context)
],
),
);
});
}