anirudhb / flutter_packages

Various flutter packages
12 stars 4 forks source link

video blinking #4

Open insinfo opened 2 years ago

insinfo commented 2 years ago

the video is playing only blinking

PS C:\MyDartProjects\riodasostras\riodasostrasapp_mob> flutter doctor -v
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [versão 10.0.22000.434], locale pt-BR)
    • Flutter version 2.8.1 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\isaque\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.3)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31702.278
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.63.2)
    • VS Code at C:\Users\isaque\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.32.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [versão 10.0.22000.434]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 97.0.4692.71
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 96.0.1054.62

• No issues found!
PS C:\MyDartProjects\riodasostras\riodasostrasapp_mob> 

https://user-images.githubusercontent.com/12227024/150841089-8ed71329-46fc-4273-a529-be92fd540f4b.mp4

anirudhb commented 2 years ago

Hi, can you share your code and/or a sample repository? Would help me reproduce (albeit, I don't have my hands on a Windows machine right now.)

insinfo commented 2 years ago
import 'package:flutter/material.dart';
import 'package:riodasostrasapp/app/shared/theme/style.dart';
import 'package:video_player/video_player.dart';

class TurismoHomePage extends StatefulWidget {
  @override
  State<TurismoHomePage> createState() => _TurismoHomePageState();
}

class _TurismoHomePageState extends State<TurismoHomePage> {

  late VideoPlayerController _controller;
  @override
  void initState() {   
    super.initState();
    _controller = VideoPlayerController.network(
        'https://www.experimenteriodasostras.com.br/storage/turismo/midias/ffec8800-09d2-45a4-9b99-09ab04b057bf.mp4')
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    var screenSize = MediaQuery.of(context).size;

    return Scaffold(
      appBar: appBarDefault(title: 'Turismo'),
      body: Container(     
        child: SingleChildScrollView(
          child: Column(
            children: [
              //video
              Container(
                color: Colors.amber,
                width: screenSize.width,
                child: _controller.value.isInitialized
                    ? AspectRatio(
                        aspectRatio: _controller.value.aspectRatio,
                        child: VideoPlayer(_controller),
                      )
                    : Container(),              
              ),
              //menu grid
              Container(
                padding: EdgeInsets.all(16),
                width: screenSize.width,
                child: Wrap(
                  spacing: 16,
                  runSpacing: 16,
                  children: [
                    Container(
                      decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.all(Radius.circular(10))),
                      padding: EdgeInsets.all(10),
                      child: Column(
                        children: [
                          Text(
                            '',
                            style: TextStyle(
                                fontFamily: 'pictogramas_turismo',
                                fontSize: 71),
                          )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {

    super.dispose();
    _controller.dispose();
  }
}

pubspec.yaml

 video_player: ^2.1.1
  video_player_windows:
    git:
      url: https://github.com/anirudhb/flutter_packages.git
      path: video_player_windows
insinfo commented 2 years ago

@anirudhb Are you using a linux or macOS machine? Because if this plugin uses ffmpeg in theory, would you implement the same logic for linux and macos too?

anirudhb commented 2 years ago

Yup, I'm planning to port this to other platforms (mainly for my ease of debugging), and pending splitting this into a separate repository. Don't have too much time at the moment to do these things though.