NEW: video player can be config without audio

This commit is contained in:
JohnE 2026-01-24 21:05:13 -08:00
parent e735aa5a49
commit 19e889617b
2 changed files with 15 additions and 0 deletions

View File

@ -31,6 +31,7 @@ class VideoConfig {
this.videoVisibilityEnum = VisibilityEnum.useFullScreen, this.videoVisibilityEnum = VisibilityEnum.useFullScreen,
this.useSafeArea = false, this.useSafeArea = false,
this.volume = 100.0, this.volume = 100.0,
this.enableAudio = true,
this.onPlayerInitialized, this.onPlayerInitialized,
}); });
@ -65,6 +66,15 @@ class VideoConfig {
/// Defaults to 100.0 (maximum volume) /// Defaults to 100.0 (maximum volume)
final double 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 /// Callback invoked when the Player is initialized
/// ///
/// Provides access to the media_kit [Player] instance for custom configuration /// Provides access to the media_kit [Player] instance for custom configuration

View File

@ -108,6 +108,11 @@ class _SplashVideoPlayerState extends State<SplashVideoPlayer> {
// Configure the player // Configure the player
await player.setVolume(videoConfig.volume); 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 // Set loop mode if controller specifies looping
if (widget.controller?.loopVideo == true) { if (widget.controller?.loopVideo == true) {
await player.setPlaylistMode(PlaylistMode.single); await player.setPlaylistMode(PlaylistMode.single);