MOD: now called VideoAspectRatio
This commit is contained in:
parent
64eb412a6f
commit
7f175ed963
|
|
@ -344,7 +344,7 @@ void main() {
|
|||
|
||||
testWidgets('supports different visibility modes',
|
||||
(WidgetTester tester) async {
|
||||
for (final mode in VisibilityEnum.values) {
|
||||
for (final mode in VideoAspectRatio.values) {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SplashVideo(
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class _DiagnosticPageState extends State<DiagnosticPage> {
|
|||
},
|
||||
videoConfig: VideoConfig(
|
||||
playImmediately: true,
|
||||
videoVisibilityEnum: VisibilityEnum.useFullScreen,
|
||||
videoVisibilityEnum: VideoAspectRatio.useFullScreen,
|
||||
onPlayerInitialized: (player) {
|
||||
debugPrint('🎬 Player initialized callback');
|
||||
setState(() {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class InitialSplashExample extends StatelessWidget {
|
|||
backgroundColor: Colors.black,
|
||||
nextScreen: const ExampleSelector(),
|
||||
videoConfig: const VideoConfig(
|
||||
videoVisibilityEnum: VisibilityEnum.useFullScreen,
|
||||
videoVisibilityEnum: VideoAspectRatio.useFullScreen,
|
||||
),
|
||||
onVideoError: (error) {
|
||||
debugPrint('Initial Splash Video Error: $error');
|
||||
|
|
@ -294,7 +294,7 @@ class AutoNavigateExample extends StatelessWidget {
|
|||
nextScreen: const HomeScreen(title: 'Auto-Navigate Example'),
|
||||
backgroundColor: Colors.black,
|
||||
videoConfig: const VideoConfig(
|
||||
videoVisibilityEnum: VisibilityEnum.useFullScreen,
|
||||
videoVisibilityEnum: VideoAspectRatio.useFullScreen,
|
||||
),
|
||||
onVideoError: (error) {
|
||||
debugPrint('Video Error in AutoNavigateExample: $error');
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/// Controls how the video is displayed on screen
|
||||
enum VisibilityEnum {
|
||||
enum VideoAspectRatio {
|
||||
/// Display video in full screen, filling the entire available space
|
||||
useFullScreen,
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class VideoConfig {
|
|||
/// Creates a VideoConfig with the specified options
|
||||
const VideoConfig({
|
||||
this.playImmediately = true,
|
||||
this.videoVisibilityEnum = VisibilityEnum.useFullScreen,
|
||||
this.videoVisibilityEnum = VideoAspectRatio.useFullScreen,
|
||||
this.useSafeArea = false,
|
||||
this.volume = 80.0,
|
||||
this.enableAudio = true,
|
||||
|
|
@ -56,10 +56,10 @@ class VideoConfig {
|
|||
|
||||
/// 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;
|
||||
/// - [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)
|
||||
///
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class _SplashVideoPlayerState extends State<SplashVideoPlayer> {
|
|||
|
||||
Widget _buildMediaWidget() {
|
||||
switch (videoConfig.videoVisibilityEnum) {
|
||||
case VisibilityEnum.useFullScreen:
|
||||
case VideoAspectRatio.useFullScreen:
|
||||
return SizedBox.fromSize(
|
||||
size: MediaQuery.sizeOf(context),
|
||||
child: Video(
|
||||
|
|
@ -269,7 +269,7 @@ class _SplashVideoPlayerState extends State<SplashVideoPlayer> {
|
|||
controls: NoVideoControls,
|
||||
),
|
||||
);
|
||||
case VisibilityEnum.useAspectRatio:
|
||||
case VideoAspectRatio.useAspectRatio:
|
||||
return AspectRatio(
|
||||
aspectRatio: player.state.width != null && player.state.height != null
|
||||
? player.state.width! / player.state.height!
|
||||
|
|
@ -279,7 +279,7 @@ class _SplashVideoPlayerState extends State<SplashVideoPlayer> {
|
|||
controls: NoVideoControls,
|
||||
),
|
||||
);
|
||||
case VisibilityEnum.none:
|
||||
case VideoAspectRatio.none:
|
||||
return Video(
|
||||
controller: controller,
|
||||
controls: NoVideoControls,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void main() {
|
|||
const config = VideoConfig();
|
||||
|
||||
expect(config.playImmediately, isTrue);
|
||||
expect(config.videoVisibilityEnum, equals(VisibilityEnum.useFullScreen));
|
||||
expect(config.videoVisibilityEnum, equals(VideoAspectRatio.useFullScreen));
|
||||
expect(config.useSafeArea, isFalse);
|
||||
expect(config.volume, equals(100.0));
|
||||
expect(config.onPlayerInitialized, isNull);
|
||||
|
|
@ -39,14 +39,14 @@ void main() {
|
|||
test('creates with custom values', () {
|
||||
final config = VideoConfig(
|
||||
playImmediately: false,
|
||||
videoVisibilityEnum: VisibilityEnum.useAspectRatio,
|
||||
videoVisibilityEnum: VideoAspectRatio.useAspectRatio,
|
||||
useSafeArea: true,
|
||||
volume: 50.0,
|
||||
onPlayerInitialized: (player) {},
|
||||
);
|
||||
|
||||
expect(config.playImmediately, isFalse);
|
||||
expect(config.videoVisibilityEnum, equals(VisibilityEnum.useAspectRatio));
|
||||
expect(config.videoVisibilityEnum, equals(VideoAspectRatio.useAspectRatio));
|
||||
expect(config.useSafeArea, isTrue);
|
||||
expect(config.volume, equals(50.0));
|
||||
expect(config.onPlayerInitialized, isNotNull);
|
||||
|
|
@ -85,15 +85,15 @@ void main() {
|
|||
|
||||
group('VisibilityEnum', () {
|
||||
test('has all expected values', () {
|
||||
expect(VisibilityEnum.values.length, equals(3));
|
||||
expect(VisibilityEnum.values, contains(VisibilityEnum.useFullScreen));
|
||||
expect(VisibilityEnum.values, contains(VisibilityEnum.useAspectRatio));
|
||||
expect(VisibilityEnum.values, contains(VisibilityEnum.none));
|
||||
expect(VideoAspectRatio.values.length, equals(3));
|
||||
expect(VideoAspectRatio.values, contains(VideoAspectRatio.useFullScreen));
|
||||
expect(VideoAspectRatio.values, contains(VideoAspectRatio.useAspectRatio));
|
||||
expect(VideoAspectRatio.values, contains(VideoAspectRatio.none));
|
||||
});
|
||||
|
||||
test('values are unique', () {
|
||||
final values = VisibilityEnum.values.toSet();
|
||||
expect(values.length, equals(VisibilityEnum.values.length));
|
||||
final values = VideoAspectRatio.values.toSet();
|
||||
expect(values.length, equals(VideoAspectRatio.values.length));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue