/* * 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:flutter/material.dart'; /// Controls how the video is displayed on screen /// Maps to Flutter's BoxFit for consistent sizing behavior enum VideoScaleMode { /// Fill the screen completely, may stretch video (BoxFit.fill) fill, /// Cover the entire screen, maintain aspect ratio, may crop edges (BoxFit.cover) cover, /// Fit inside screen, maintain aspect ratio, may have letterboxing (BoxFit.contain) contain, /// Fit the width, maintain aspect ratio (BoxFit.fitWidth) fitWidth, /// Fit the height, maintain aspect ratio (BoxFit.fitHeight) fitHeight, /// Display at original size (BoxFit.none) none, /// Like contain but won't scale up beyond original size (BoxFit.scaleDown) scaleDown, } /// Extension to convert VideoScaleMode to BoxFit extension VideoScaleModeExtension on VideoScaleMode { /// Convert to Flutter's BoxFit BoxFit toBoxFit() { switch (this) { case VideoScaleMode.fill: return BoxFit.fill; case VideoScaleMode.cover: return BoxFit.cover; case VideoScaleMode.contain: return BoxFit.contain; case VideoScaleMode.fitWidth: return BoxFit.fitWidth; case VideoScaleMode.fitHeight: return BoxFit.fitHeight; case VideoScaleMode.none: return BoxFit.none; case VideoScaleMode.scaleDown: return BoxFit.scaleDown; } } } /// Hardware decode mode for video playback /// /// Controls how video decoding is handled by the underlying media player. /// When null is passed to VideoConfig, smart platform defaults are used: /// - Windows: [HwdecMode.autoSafe] (avoids CUDA errors on non-NVIDIA systems) /// - Other platforms: [HwdecMode.auto] enum HwdecMode { /// Try all hardware decode methods in order /// /// May log errors on Windows when CUDA isn't available before falling back. /// Prefer [autoSafe] on Windows to avoid these errors. auto('auto'), /// Try safe hardware methods only, skip problematic ones /// /// Recommended for Windows - works on NVIDIA, AMD, and Intel GPUs /// without logging CUDA errors on non-NVIDIA systems. autoSafe('auto-safe'), /// Auto-detect but copy frames to system memory /// /// Safer but slightly more overhead than direct rendering. autoCopy('auto-copy'), /// Disable hardware acceleration entirely /// /// Uses software decoding only. Higher CPU usage but most compatible. disabled('no'), /// Force Direct3D 11 Video Acceleration (Windows) /// /// Works on modern NVIDIA (GeForce 400+), AMD (Radeon HD 5000+), /// and Intel (HD Graphics) GPUs. d3d11va('d3d11va'), /// Force DirectX Video Acceleration 2 (Windows) /// /// Legacy option for older Windows systems. Use [d3d11va] on modern systems. dxva2('dxva2'), /// Force VideoToolbox (macOS/iOS) /// /// Apple's hardware acceleration framework. videoToolbox('videotoolbox'), /// Force VA-API (Linux) /// /// Video Acceleration API for Linux systems with Intel, AMD, or NVIDIA GPUs. vaapi('vaapi'), /// Force MediaCodec (Android) /// /// Android's native hardware codec API. mediaCodec('mediacodec'); const HwdecMode(this.value); /// The string value passed to media_kit/mpv final String value; }