lum_splash_video/lib/video_config.dart

81 lines
2.9 KiB
Dart

/*
* 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.videoVisibilityEnum = VisibilityEnum.useFullScreen,
this.useSafeArea = false,
this.volume = 100.0,
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
///
/// - [VisibilityEnum.useFullScreen]: Fill the entire screen
/// - [VisibilityEnum.useAspectRatio]: Maintain video's aspect ratio
/// - [VisibilityEnum.none]: No special sizing
final VisibilityEnum videoVisibilityEnum;
/// Initial volume level (0.0 to 100.0)
///
/// Defaults to 100.0 (maximum volume)
final double volume;
/// 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;
}