alexmercerind / dart_vlc

Flutter bindings to libVLC.
GNU Lesser General Public License v2.1
512 stars 137 forks source link

[windows] Video can not be displayed after packaging #295

Closed meng-fucius closed 2 years ago

meng-fucius commented 2 years ago

Describe the bug Everything is ok in the debug mode,but there is no video playback under releas mode;

Minimal reproducible code

import 'package:dart_vlc/dart_vlc.dart';
import 'package:flutter/material.dart';
void main() {
  DartVLC.initialize(useFlutterNativeView: true);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

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

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final videoPlayer = Player(id: 0,registerTexture: false);
  final audioPlayer = Player(id:1);

  @override
  void initState() {
      videoPlayer.open( Media.asset(
          'assets/video.webm'
      ),autoStart: true);
      videoPlayer.setPlaylistMode(PlaylistMode.loop);
      audioPlayer.open( Media.asset(
          'assets/bailuguiting.mp3'
      ),autoStart: true);
    audioPlayer.setPlaylistMode(PlaylistMode.loop);
    super.initState();
  }

  @override
  void dispose() {
    videoPlayer.dispose();
    audioPlayer.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return NativeVideo(
      player: videoPlayer,
        height: double.infinity,
        width: double.infinity,
        fit: BoxFit.cover,
        showControls: false,
    );
  }
}

Flutter logs

PS G:\git_repository\kamisato_ayaka_wallpaper> fvm flutter run -d Windows --release
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Launching lib\main.dart on Windows in release mode...
Building Windows application...                                 

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
flutter: LateInitializationError: Field 'dynamicLibrary' has not been initialized.
flutter: #0      PlayerFFI.create (package:dart_vlc_ffi/src/internal/ffi.dart)
flutter: #1      new Player (package:dart_vlc_ffi/src/player.dart)
flutter: #2      new Player (package:dart_vlc/dart_vlc.dart:66)
flutter: #3      new _MyHomePageState (package:kamisato_ayaka_wallpaper/main.dart:33)
flutter: #4      MyHomePage.createState (package:kamisato_ayaka_wallpaper/main.dart:29)
flutter: #5      new StatefulElement (package:flutter/src/widgets/framework.dart:4891)
flutter: #6      StatefulWidget.createElement (package:flutter/src/widgets/framework.dart:758)
flutter: #7      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3812)
flutter: #8      Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #9      SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #10     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #11     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #13     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #14     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #15     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
flutter: #16     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #17     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #18     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #19     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #20     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #21     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #22     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #23     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #24     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #25     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4977)
flutter: #26     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #27     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #28     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4968)
flutter: #29     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
flutter: #30     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #31     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #32     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #33     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #34     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #36     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4977)
flutter: #37     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #38     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #39     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4968)
flutter: #40     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
flutter: #41     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #42     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #43     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #44     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #45     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #46     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #47     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #48     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #49     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
flutter: #50     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #51     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #52     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #53     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #54     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #55     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #56     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4977)
flutter: #57     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #58     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #59     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4968)
flutter: #60     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
flutter: #61     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #62     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #63     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #64     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #65     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #66     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #67     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #68     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #69     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #70     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4977)
flutter: #71     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #72     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #73     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4968)
flutter: #74     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
flutter: #75     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #76     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #91     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6215)
flutter: #92     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3817)
flutter: #93     Element.updateChild (package:flutter/src/widgets/framework.dart:3551)
flutter: #94     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4832)
flutter: #95     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4977)
flutter: #96     Element.rebuild (package:flutter/src/widgets/framework.dart:4529)
flutter: #97     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4787)
flutter: #98     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4968)
flutter: #99     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4781)
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [版本 10.0.18363.1556], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.5)
[√] Android Studio (version 2021.1)
[√] IntelliJ IDEA Community Edition (version 2021.3)
[√] Connected device (4 available)
[√] HTTP Host Availability

Operating system:

Screenshots image

alexmercerind commented 2 years ago

Add await before DartVLC.initialize.

alexmercerind commented 2 years ago

Please close, if fixed.

meng-fucius commented 2 years ago

It works, thanks.

mcquenji commented 1 year ago

I am not sure if should open a new issue or not, but it seems this issue is back again, and using the latest version the initialize method does not return a Future. It works fine in debug mode but in release mode it just shows a blank screen. Although I can hear the audio...

Have I missed anything?

flutter --version

Flutter 3.7.12 • channel stable • https://github.com/flutter/flutter.git Framework • revision 4d9e56e694 (4 weeks ago) • 2023-04-17 21:47:46 -0400 Engine • revision 1a65d409c7 Tools • Dart 2.19.6 • DevTools 2.20.1

My main method:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  DartVLC.initialize();
  await windowManager.ensureInitialized();

  var logDisk = LogDiskService();

  Logger.root.onRecord.listen((event) async {
    if (kDebugMode) print(event);
    await logDisk.write(event.toString());
  });

  await SystemTheme.accentColor.load();

  doWhenWindowReady(() {
    appWindow.title = "Testytest";
    appWindow.alignment = Alignment.center;
    appWindow.show();
  });

  runApp(const ProviderScope(child: App()));
}

These are the error messages if they help:

[00000267561de8b0] main vout display error: Failed to set on top
[00000267561de3f0] main vout display error: Failed to set on top
[h264 @ 000002675602c580] get_buffer() failed
[h264 @ 000002675602c580] thread_get_buffer() failed
[h264 @ 000002675602c580] decode_slice_header error
[h264 @ 000002675602c580] no frame!

Also, I get these warnings at compile time (Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich --> Converting "size_t" to "int32_t", possible data loss):

E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(470,59): warning C4267: "=": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(491,51): warning C4267: "=": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(502,57): warning C4267: "Argument": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(503,46): warning C4267: "Argument": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(503,59): warning C4267: "Argument": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(509,72): warning C4267: "Argument": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(510,46): warning C4267: "Argument": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\api\api.cc(510,59): warning C4267: "Argument": Konvertierung von "size_t" nach "int32_t", Datenverlust m�glich [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
E:\Program Files\GitHub\testytest\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\core\player\player.cc(327,9): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [E:\Program Files\GitHub\testytest\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]

Thanks for this amazing package 👍