callBackWhenVideoStateChange method
void
callBackWhenVideoStateChange(
{ - required dynamic onVideoStateChange(
- VideoState state
)?,
})
Implementation
void callBackWhenVideoStateChange({
required Function(VideoState state)? onVideoStateChange,
}) {
controller.addJavaScriptHandler(
handlerName: 'onVideoStateChange',
callback: (args) {
final String state = args.first;
VideoState? videoState;
switch (state) {
case 'playing':
videoState = VideoState.playing;
break;
case 'paused':
videoState = VideoState.paused;
break;
case 'muted':
videoState = VideoState.muted;
break;
case 'unmuted':
videoState = VideoState.unmuted;
break;
}
if (videoState != null) {
onVideoStateChange?.call(videoState);
print('<<< Video state changed: $state >>>');
}
return null;
},
);
}