balvinderz / video_player_web_hls

Supports hls on chrome and other browsers.
BSD 3-Clause "New" or "Revised" License
52 stars 61 forks source link

Mobile chromium browser VideoController value error #33

Closed bluejoyq closed 1 year ago

bluejoyq commented 2 years ago

First of all, thank you for creating such a wonderful library. However, a problem occurred during use.

problem

VideoControllerValue is not initialized in the Mobile Chromium browser.

image

Firefox mobile is okay, but with Safari, Edge, Chrome, and Samsung Internet browsers occurs problem. Only with hls video.

code

import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late final VideoPlayerController videoPlayerController;

  @override
  void initState() {
    super.initState();
    videoPlayerController = VideoPlayerController.network(
      'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
      formatHint: VideoFormat.hls,
    )..initialize().then((_) {
        // videoPlayerController.play();
        videoPlayerController.setLooping(true);
      });
    videoPlayerController.addListener(() {
      debugPrint(videoPlayerController.value.toString());
    });
  }

  @override
  void dispose() {
    videoPlayerController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: videoPlayerController.value.isInitialized
            ? AspectRatio(
                aspectRatio: videoPlayerController.value.aspectRatio,
                child: VideoPlayer(videoPlayerController),
              )
            : Container(),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            videoPlayerController.value.isPlaying
                ? videoPlayerController.pause()
                : videoPlayerController.play();
          });
        },
        child: Icon(
          videoPlayerController.value.isPlaying
              ? Icons.pause
              : Icons.play_arrow,
        ),
      ),
    );
  }
}

flutter doctor -v

[✓] Flutter (Channel stable, 3.3.0, on macOS 12.6 21G115 darwin-arm, locale ko-KR)
    • Flutter version 3.3.0 on channel stable at /Users/bluejoy/development/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffccd96b62 (3달 전), 2022-08-29 17:28:57 -0700
    • Engine revision 5e9e0e0aa8
    • Dart version 2.18.0
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/bluejoy/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 70.2.5
    • Dart plugin version 222.4167.21

[✓] VS Code (version 1.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.6 21G115 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 107.0.5304.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
balvinderz commented 2 years ago

Hi @bluejoyq , thanks for reporting this issue. I will check this during the weekend.

balvinderz commented 1 year ago

try 1.0.0 @bluejoyq

bluejoyq commented 1 year ago

@balvinderz Sadly, version 1.0.0 doesn't work either. After opening the web server with flutter run -d web-server --web-render canvaskit in the code above, the same log is still output when connected from mobile.

balvinderz commented 1 year ago

@bluejoyq not able to repro :/ even in the ss attached by you above , isInitialised is true in both the logs

bluejoyq commented 1 year ago

Thank you for leaving comments even though you must be busy :)

image

isInitialized is changed but other values remain the same as the default values.

Like the screenshot above.

balvinderz commented 1 year ago

Hi @bluejoyq i was able to repro and fix this. Fix has been published in 1.0.0+1

balvinderz commented 1 year ago

Let me know if the new version fixes it for you. Then i will close this issue.

bluejoyq commented 1 year ago

@balvinderg It works perfectly well. Thank you for your efforts.

balvinderz commented 1 year ago

Thanks for reporting and confirming :) Closing this issue