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