72 lines
2.4 KiB
Dart
72 lines
2.4 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: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;
|
|
}
|
|
}
|
|
}
|