Skip to content

[video_player] [Android] Video aspect ratio error #42945

Closed

Description

@PrismaSoftGC

Video aspect ratio error

Video size does not match the width or exact height of the device screen. We noticed that this error occurs on devices with android operating system version 6.0 or lower.

Screenshot_20191017-163916

Activity

  1. ketanm commented on Oct 18, 2019

    @ketanm

    Please attach flutter doctor -v output. Also does same APK work on 6.0+?

  2. PrismaSoftGC commented on Oct 18, 2019

    @PrismaSoftGC
    Author

    Please attach flutter doctor -v output. Also does same APK work on 6.0+?

    It does not work on version 6.0, yesterday I tested on 5.0 and also did not work. It only works on version 6.0.1 or higher. I would very much like to be able to correct this error as API 6.0 covers the largest slice of android users.

    Captura de tela de 2019-10-18 08-25-30

  3. PrismaSoftGC commented on Oct 21, 2019

    @PrismaSoftGC
    Author

    someone to help me?

  4. TahaTesser commented on Mar 10, 2020

    @TahaTesser
    Contributor

    Related to #51250

  5. maheshj01 commented on Jun 25, 2021

    @maheshj01
    Member

    Hi @PrismaSoftGC ,
    I am not able to replicate the issue on the latest stable version of flutter using video_player: ^2.1.6. I tested on android K20 pro and android 5 .
    I would request you to upgrade to latest version of flutter and verify the issue.

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-arm, locale en-IN)
        • Flutter version 2.2.2 at /Users/mahesh/Documents/flutter
        • Framework revision d79295af24 (2 weeks ago), 2021-06-11 08:56:01 -0700
        • Engine revision 91c9fc8fe0
        • Dart version 2.13.3
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.4, Build version 12D4e
        • CocoaPods version 1.10.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
    
    Sample code
    import 'package:flutter/material.dart';
    import 'package:video_player/video_player.dart';
    
    void main() {
      runApp(VideoSampleCode());
    }
    
    class VideoSampleCode extends StatefulWidget {
      @override
      _VideoSampleCodeState createState() => _VideoSampleCodeState();
    }
    
    class _VideoSampleCodeState extends State<VideoSampleCode> {
      late VideoPlayerController _controller;
    
      @override
      void initState() {
        super.initState();
        _controller = VideoPlayerController.network(
            'https://res.cloudinary.com/demo/video/upload/f_mp4/dog.mp4')
          ..initialize().then((_) {
            // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
            setState(() {});
          });
        _controller.setLooping(true);
      }
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Video Demo',
          home: Scaffold(
            body: Stack(
              children: [
                VideoPlayer(_controller),
                Positioned(
                    bottom: 20,
                    right: 20,
                    child: Container(
                      height: 100,
                      child: _controller.value.isInitialized
                          ? AspectRatio(
                              aspectRatio: _controller.value.aspectRatio,
                              child: VideoPlayer(_controller),
                            )
                          : Container(),
                    )),
                Positioned(
                    top: 20,
                    left: 20,
                    child: Container(
                      height: 100,
                      width: 200,
                      child: _controller.value.isInitialized
                          ? AspectRatio(
                              aspectRatio: _controller.value.aspectRatio,
                              child: VideoPlayer(_controller),
                            )
                          : Container(),
                    )),
                  Positioned(
                    top: 200,
                    right: 20,
                    child: Container(
                      height: 100,
                      child: _controller.value.isInitialized
                          ? AspectRatio(
                              aspectRatio: _controller.value.aspectRatio,
                              child: VideoPlayer(_controller),
                            )
                          : Container(),
                    )),
              ],
            ),
            floatingActionButton: FloatingActionButton(
              onPressed: () {
                setState(() {
                  _controller.value.isPlaying
                      ? _controller.pause()
                      : _controller.play();
                });
              },
              child: Icon(
                _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
              ),
            ),
          ),
        );
      }
    
      @override
      void dispose() {
        super.dispose();
        _controller.dispose();
      }
    }
    
    Screenshot taken on mi4i (Android 5) with Different Sizes of video_player widget

    Feel free to write back if you still encounter the issue.
    Thank you.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 25, 2021
  7. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 16, 2021
  8. TahaTesser commented on Jul 16, 2021

    @TahaTesser
    Contributor

    Without additional information, we are unfortunately not sure how to resolve this issue.
    We are therefore reluctantly going to close this bug for now.
    Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
    Thanks for your contribution.

    Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of flutter doctor -v.
    All system setups can be slightly different, so it's always better to open new issues and reference related issues.

  9. added
    r: timeoutIssue is closed due to author not providing the requested details in time
    on Jul 16, 2021
  10. github-actions commented on Jul 30, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Jul 30, 2021
  12. added
    P3Issues that are less important to the Flutter project
    and removed on Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectp: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyr: timeoutIssue is closed due to author not providing the requested details in time

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions