91 lines
3.2 KiB
Dart
91 lines
3.2 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 = VideoAspectRatio.useFullScreen,
|
|
this.useSafeArea = false,
|
|
this.volume = 80.0,
|
|
this.enableAudio = true,
|
|
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
|
|
///
|
|
/// - [VideoAspectRatio.useFullScreen]: Fill the entire screen
|
|
/// - [VideoAspectRatio.useAspectRatio]: Maintain video's aspect ratio
|
|
/// - [VideoAspectRatio.none]: No special sizing
|
|
final VideoAspectRatio videoVisibilityEnum;
|
|
|
|
/// 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;
|
|
|
|
/// 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;
|
|
}
|