abdelaziz-mahdy / flutter_meedu_videoplayer

Cross-Platform Video Player for flutter
https://abdelaziz-mahdy.github.io/flutter_meedu_videoplayer/
MIT License
132 stars 69 forks source link

flutter linux desktop error #124

Closed inhohwangg closed 11 months ago

inhohwangg commented 1 year ago

When I entered the command flutter run -d linux I got the following error

[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
desktop_ui: ../../src/xcb_io.c:725: _XReply: assertion `!xcb_xlib_threads_sequence_lost' fail.
Lost connection to device.

I used this package like this

void main() async {
  try {
    WidgetsFlutterBinding.ensureInitialized();
    try {
      await initMeeduPlayer(
          androidUseMediaKit: false,
          iosUseMediaKit: false,
          logLevel: MPVLogLevel.error);
    } catch (e) {
      print('Error initializing Meedu Player: $e');
    }
    } if (Platform.isLinux) {
      // Must add this line.
      await windowManager.ensureInitialized();

      WindowOptions windowOptions = WindowOptions(
        //! fullScreen
        fullScreen: true,
        center: true,
        backgroundColor: Colors.transparent,
        skipTaskbar: false,
        titleBarStyle: TitleBarStyle.hidden,
      );
      windowManager.waitUntilReadyToShow(windowOptions, () async {
        await windowManager.show();
        await windowManager.focus();
        //! Position.
        // await windowManager.setPosition(Offset(2240, 0));
        //! Size
        // await windowManager.setSize(Size(400, 400));
      });
    }
  } catch (e, stackTrace) {
    print('Error initializing window manager: $e');
    print(stackTrace); // Print the stack trace information of the error.
  }

  } await GetStorage.init();
  HttpOverrides.global = NoCheckCertificateHttpOverrides();
  runApp(MyApp());
}

In main.dart, initialize initMeeduPlayer and call

In home_page.dart, I looked at the code in basicExample and wrote it

The error occurs in initMeeduPlayer().

This is because commenting out initMeeduPlayer() prevents the error from occurring.

Can you tell me how to resolve the error?

abdelaziz-mahdy commented 1 year ago

can you test https://github.com/alexmercerind/media_kit example

looks like a media_kit issue to me since i am using it to run videos on linux,

also can you provide flutter doctor? and version of package used from pubspec.yaml

also did you follow the linux setup?

inhohwangg commented 1 year ago

My flutter doctor

[✓] Flutter (Channel stable, 3.10.5, on Debian GNU/Linux 11 (bullseye) 5.10.0-23-amd64, locale ko_KR.UTF-8)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)

[✓] Chrome - develop for the web

[✓] Linux toolchain - develop for Linux desktop

[✓] Android Studio (version 2022.2)

[✓] Android Studio (version 2021.3)

[✓] Android Studio

[✓] VS Code (version 1.74.3)

[✓] VS Code (version 1.75.0-insider)

[✓] Connected device (2 available)

[✓] Network resources

I initialized initMeeduPlayer in main.dart

void main() async { try { WidgetsFlutterBinding.ensureInitialized(); await initMeeduPlayer(); if (Platform.isLinux) { // Must add this line. await windowManager.ensureInitialized();

  WindowOptions windowOptions = WindowOptions(
    fullScreen: true,
    center: true,
    backgroundColor: Colors.transparent,
    skipTaskbar: false,
    titleBarStyle: TitleBarStyle.hidden,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
    // await windowManager.setPosition(Offset(2240, 0));
    // await windowManager.setSize(Size(400, 400));
  });
}

} catch (e, stackTrace) { print('Error initializing window manager: $e'); print(stackTrace); }

} await GetStorage.init(); HttpOverrides.global = NoCheckCertificateHttpOverrides(); runApp(MyApp()); } And for the rest of the code, I referenced the basicExample in the link below. https://zezo357.github.io/flutter_meedu_videoplayer/#/?id=linux

abdelaziz-mahdy commented 1 year ago

Did you try media_kit example?

And did you follow the Linux setup?

inhohwangg commented 1 year ago

I used the example you gave and it failed And the Linux settings what should I follow?

I installed only the packages listed in the official documentation

abdelaziz-mahdy commented 1 year ago

sudo apt install libmpv-dev mpv

This needed,

And I recommend you test media_kit to figure out if it's a problem from this package or media_kit

inhohwangg commented 1 year ago

I installed sudo apt install libmpv-dev mpv. I then used media_kit and succeeded in getting the video on the screen. http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4` The above link is the one I tested

But I still get

[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.

I got the above error.

abdelaziz-mahdy commented 1 year ago

Well then you will need to open the issue in media_kit since its an issue in their package

As I mentioned I am only using media_kit to render video on Linux.