diff --git a/lib/video_config.dart b/lib/video_config.dart index 5106901..71adb64 100644 --- a/lib/video_config.dart +++ b/lib/video_config.dart @@ -31,6 +31,7 @@ class VideoConfig { this.videoVisibilityEnum = VisibilityEnum.useFullScreen, this.useSafeArea = false, this.volume = 100.0, + this.enableAudio = true, this.onPlayerInitialized, }); @@ -65,6 +66,15 @@ class VideoConfig { /// Defaults to 100.0 (maximum volume) final double volume; + /// Whether to enable audio playback + /// + /// When false, the audio track will be disabled entirely, which is more + /// efficient than just setting volume to 0. This is useful for videos + /// that should be silent (e.g., splash screens, decorative backgrounds). + /// + /// Defaults to true (audio enabled) + final bool enableAudio; + /// Callback invoked when the Player is initialized /// /// Provides access to the media_kit [Player] instance for custom configuration diff --git a/lib/widgets/splash_video_player_w.dart b/lib/widgets/splash_video_player_w.dart index 520d090..4f8c710 100644 --- a/lib/widgets/splash_video_player_w.dart +++ b/lib/widgets/splash_video_player_w.dart @@ -108,6 +108,11 @@ class _SplashVideoPlayerState extends State { // Configure the player await player.setVolume(videoConfig.volume); + // Disable audio track if audio is not enabled + if (!videoConfig.enableAudio) { + await player.setAudioTrack(AudioTrack.no()); + } + // Set loop mode if controller specifies looping if (widget.controller?.loopVideo == true) { await player.setPlaylistMode(PlaylistMode.single);