diff --git a/example/lib/animation_player/landscape_controls.dart b/example/lib/animation_player/landscape_controls.dart index d7865e8b..ee320ac5 100644 --- a/example/lib/animation_player/landscape_controls.dart +++ b/example/lib/animation_player/landscape_controls.dart @@ -5,11 +5,20 @@ import 'package:provider/provider.dart'; class AnimationPlayerLandscapeControls extends StatelessWidget { const AnimationPlayerLandscapeControls( - {Key? key, required this.animationPlayerDataManager}) + {Key? key, + this.onMute, + this.onUnmute, + required this.animationPlayerDataManager}) : super(key: key); final AnimationPlayerDataManager animationPlayerDataManager; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; + @override Widget build(BuildContext context) { FlickVideoManager flickVideoManager = @@ -81,7 +90,11 @@ class AnimationPlayerLandscapeControls extends StatelessWidget { SizedBox( width: 10, ), - FlickSoundToggle(size: 30), + FlickSoundToggle( + size: 30, + onMute: onMute, + onUnmute: onUnmute, + ), SizedBox( width: 20, ), diff --git a/example/lib/animation_player/portrait_video_controls.dart b/example/lib/animation_player/portrait_video_controls.dart index dab7f705..b45d7350 100644 --- a/example/lib/animation_player/portrait_video_controls.dart +++ b/example/lib/animation_player/portrait_video_controls.dart @@ -8,10 +8,17 @@ class AnimationPlayerPortraitVideoControls extends StatelessWidget { Key? key, this.pauseOnTap, this.dataManager, + this.onMute, + this.onUnmute, }) : super(key: key); final bool? pauseOnTap; final AnimationPlayerDataManager? dataManager; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; @override Widget build(BuildContext context) { FlickVideoManager flickVideoManager = @@ -81,7 +88,10 @@ class AnimationPlayerPortraitVideoControls extends StatelessWidget { FlickAutoHideChild( autoHide: false, showIfVideoNotInitialized: false, - child: FlickSoundToggle(), + child: FlickSoundToggle( + onMute: onMute, + onUnmute: onUnmute, + ), ), FlickAutoHideChild( autoHide: false, diff --git a/example/lib/feed_player/portrait_controls.dart b/example/lib/feed_player/portrait_controls.dart index 915b01ca..2aa8874b 100644 --- a/example/lib/feed_player/portrait_controls.dart +++ b/example/lib/feed_player/portrait_controls.dart @@ -5,12 +5,22 @@ import './multi_manager/flick_multi_manager.dart'; class FeedPlayerPortraitControls extends StatelessWidget { const FeedPlayerPortraitControls( - {Key? key, this.flickMultiManager, this.flickManager}) + {Key? key, + this.flickMultiManager, + this.onMute, + this.onUnmute, + this.flickManager}) : super(key: key); final FlickMultiManager? flickMultiManager; final FlickManager? flickManager; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; + @override Widget build(BuildContext context) { FlickDisplayManager displayManager = @@ -61,6 +71,8 @@ class FeedPlayerPortraitControls extends StatelessWidget { child: FlickSoundToggle( toggleMute: () => flickMultiManager?.toggleMute(), color: Colors.white, + onMute: onMute, + onUnmute: onUnmute, ), ), // FlickFullScreenToggle(), diff --git a/example/lib/landscape_player/landscape_player_controls.dart b/example/lib/landscape_player/landscape_player_controls.dart index 6c58105c..f4cc399a 100644 --- a/example/lib/landscape_player/landscape_player_controls.dart +++ b/example/lib/landscape_player/landscape_player_controls.dart @@ -1,4 +1,3 @@ - import 'package:example/landscape_player/play_toggle.dart'; import 'package:flick_video_player/flick_video_player.dart'; import 'package:flutter/material.dart'; @@ -6,11 +5,21 @@ import 'package:flutter/services.dart'; class LandscapePlayerControls extends StatelessWidget { const LandscapePlayerControls( - {Key? key, this.iconSize = 20, this.fontSize = 12}) + {Key? key, + this.iconSize = 20, + this.onMute, + this.onUnmute, + this.fontSize = 12}) : super(key: key); final double iconSize; final double fontSize; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; + @override Widget build(BuildContext context) { return Stack( @@ -116,6 +125,8 @@ class LandscapePlayerControls extends StatelessWidget { ), FlickSoundToggle( size: 20, + onMute: onMute, + onUnmute: onUnmute, ), ], ), diff --git a/example/lib/web_video_player/web_video_control.dart b/example/lib/web_video_player/web_video_control.dart index 5fcb1d06..2ef6da94 100644 --- a/example/lib/web_video_player/web_video_control.dart +++ b/example/lib/web_video_player/web_video_control.dart @@ -9,6 +9,8 @@ class WebVideoControl extends StatelessWidget { {Key? key, this.iconSize = 20, this.fontSize = 12, + this.onMute, + this.onUnmute, this.progressBarSettings, this.dataManager}) : super(key: key); @@ -21,6 +23,12 @@ class WebVideoControl extends StatelessWidget { /// [dataManager] is used to handle video controls. final DataManager? dataManager; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; + /// Font size. /// /// This size is used for all the text. @@ -124,6 +132,8 @@ class WebVideoControl extends StatelessWidget { ), FlickSoundToggle( size: iconSize, + onMute: onMute, + onUnmute: onUnmute, ), SizedBox( width: iconSize / 2, diff --git a/lib/src/controls/flick_portrait_controls.dart b/lib/src/controls/flick_portrait_controls.dart index d4e9fded..0e49a773 100644 --- a/lib/src/controls/flick_portrait_controls.dart +++ b/lib/src/controls/flick_portrait_controls.dart @@ -7,6 +7,8 @@ class FlickPortraitControls extends StatelessWidget { {Key? key, this.iconSize = 20, this.fontSize = 12, + this.onMute, + this.onUnmute, this.progressBarSettings}) : super(key: key); @@ -15,6 +17,12 @@ class FlickPortraitControls extends StatelessWidget { /// This size is used for all the player icons. final double iconSize; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; + /// Font size. /// /// This size is used for all the text. @@ -70,6 +78,8 @@ class FlickPortraitControls extends StatelessWidget { ), FlickSoundToggle( size: iconSize, + onMute: onMute, + onUnmute: onUnmute, ), SizedBox( width: iconSize / 2, diff --git a/lib/src/widgets/flick_sound_toggle.dart b/lib/src/widgets/flick_sound_toggle.dart index f0edf553..faf9dea2 100644 --- a/lib/src/widgets/flick_sound_toggle.dart +++ b/lib/src/widgets/flick_sound_toggle.dart @@ -8,6 +8,8 @@ class FlickSoundToggle extends StatelessWidget { Key? key, this.muteChild, this.unmuteChild, + this.onMute, + this.onUnmute, this.toggleMute, this.size, this.color, @@ -25,6 +27,12 @@ class FlickSoundToggle extends StatelessWidget { /// Default - Icon(Icons.volume_up) final Widget? unmuteChild; + /// This function is used for telling whatwill happen on mute press. + final VoidCallback? onMute; + + /// This function is used for telling whatwill happen on unmute press. + final VoidCallback? onUnmute; + /// Function called onTap of visible child. /// /// Default action - @@ -50,18 +58,24 @@ class FlickSoundToggle extends StatelessWidget { FlickControlManager controlManager = Provider.of(context); - Widget muteWidget = muteChild ?? - Icon( - Icons.volume_off, - size: size, - color: color, - ); - Widget unmuteWidget = unmuteChild ?? - Icon( - Icons.volume_up, - size: size, - color: color, - ); + Widget muteWidget = GestureDetector( + onTap: onMute == null ? () {} : onMute, + child: muteChild ?? + Icon( + Icons.volume_off, + size: size, + color: color, + ), + ); + Widget unmuteWidget = GestureDetector( + onTap: onUnmute == null ? () {} : onUnmute, + child: unmuteChild ?? + Icon( + Icons.volume_up, + size: size, + color: color, + ), + ); Widget child = controlManager.isMute ? muteWidget : unmuteWidget;