NEW: video player can be config without audio
This commit is contained in:
parent
e735aa5a49
commit
19e889617b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ class _SplashVideoPlayerState extends State<SplashVideoPlayer> {
|
|||
// 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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue