/* * Copyright (c) 2025 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import 'package:media_kit/media_kit.dart'; import 'package:splash_video/splash_video_enums.dart'; /// Configuration options for video splash screen class VideoConfig { /// Creates a VideoConfig with the specified options const VideoConfig({ this.playImmediately = true, this.scale = VideoScaleMode.cover, this.useSafeArea = false, this.volume = 80.0, this.enableAudio = true, this.hwdec, this.onPlayerInitialized, }); /// Whether to start playing the video immediately after initialization /// /// If false, you must call `play()` explicitly through [onPlayerInitialized] /// ```dart /// VideoConfig( /// playImmediately: false, /// onPlayerInitialized: (player) { /// // Custom logic before playing /// player.play(); /// }, /// ) /// ``` final bool playImmediately; /// Whether to wrap the video in a SafeArea widget /// /// Use this to avoid notches, status bars, and other system UI elements final bool useSafeArea; /// How the video should be displayed on screen /// /// - [VideoScaleMode.cover]: Fill screen, maintain aspect ratio, may crop (default for splash) /// - [VideoScaleMode.contain]: Fit inside screen, maintain aspect ratio, may letterbox /// - [VideoScaleMode.fill]: Stretch to fill (ignores aspect ratio) /// - [VideoScaleMode.fitWidth]: Fit width, maintain aspect ratio /// - [VideoScaleMode.fitHeight]: Fit height, maintain aspect ratio /// - [VideoScaleMode.none]: Original size /// - [VideoScaleMode.scaleDown]: Like contain but won't enlarge final VideoScaleMode scale; /// Deprecated: Use [scale] instead @Deprecated('Use fitMode instead. Will be removed in v1.0.0') VideoScaleMode get videoVisibilityEnum => scale; /// Initial volume level (0.0 to 100.0) /// /// 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; /// Hardware decode mode for video playback /// /// Controls how video decoding is handled. When null, uses smart defaults: /// - Windows: [HwdecMode.autoSafe] (avoids CUDA errors on non-NVIDIA systems) /// - Other platforms: [HwdecMode.auto] /// /// Example: /// ```dart /// VideoConfig( /// hwdec: HwdecMode.autoSafe, // Explicit safe mode /// ) /// ``` /// /// See [HwdecMode] for all available options. final HwdecMode? hwdec; /// Callback invoked when the Player is initialized /// /// Provides access to the media_kit [Player] instance for custom configuration /// ```dart /// VideoConfig( /// onPlayerInitialized: (player) { /// print('Player ready: ${player.state.duration}'); /// // You can access player.state or call player methods here /// }, /// ) /// ``` final void Function(Player player)? onPlayerInitialized; }