dart_vlc icon indicating copy to clipboard operation
dart_vlc copied to clipboard

flutter native view all black (when playing local file)

Open abdelaziz-mahdy opened this issue 2 years ago • 7 comments

Describe the bug

Flutter native view all black (when playing local file) but the view is working correctly on links

Another issue when going to full screen using window manager the top bar of flutter native view doesn't go away also, there is a space on each edge (my guess related to flutter native view too)

Media

downloaded video files

Minimal reproducible code

https://github.com/zezo357/flutter_meedu_videoplayer

Flutter logs

paste output of **flutter run --verbose** here (replace this line, and make sure to include --verbose flag).
paste output of **flutter doctor --verbose** here (replace this line, and make sure to include --verbose flag).

Operating system:

  • Platform: e.g. Windows, Ubuntu or macOS etc.
  • OS version: Windows 11 21H2, Ubuntu 20.04 etc.

Other details:

  • [x] I confirm this is not a bug in the VLC app & only dart_vlc.
  • [ ] I have donated / sponsored dart_vlc.

Screenshots image

abdelaziz-mahdy avatar May 16 '22 10:05 abdelaziz-mahdy

This is confusing. I'm able to play local files perfectly. There shouldn't be difference, since the video output is itself a VLC window. Make sure you're using Media.file constructor.

For the full screen, yeah that's something needs to be handled separately with flutter_native_view. It'd take some time too.

alexmercerind avatar May 16 '22 10:05 alexmercerind

this is how i create the player


    Player player = Player(
        id: randomNumber,
        commandlineArguments: [
          //"-vvv",
          '--http-referrer=' + refer,
          '--http-reconnect',
          '--sout-livehttp-caching',
          '--network-caching=60000',
          '--file-caching=60000'
        ],
        registerTexture: !Platform.isWindows); // create a new video controller
    if (dataSource.type == DataSourceType.asset) {
      player.open(
        Media.asset(dataSource.source!),
        autoStart: _autoplay,
      );
    } else if (dataSource.type == DataSourceType.network) {
      print(dataSource.source!);
      player.open(
        Media.network(
          dataSource.source!,
          timeout: Duration(seconds: 10),
          //startTime: seekTo
        ),
        autoStart: _autoplay,
      );
    } else {
      player.open(
        Media.file(
          dataSource.file!,
          //startTime: seekTo
        ),
        autoStart: _autoplay,
      );
    }

is this wrong?

also sound is working just the screen is black

abdelaziz-mahdy avatar May 16 '22 10:05 abdelaziz-mahdy

ok playing local files works, I will check more and tell you where is the main problem

abdelaziz-mahdy avatar May 16 '22 10:05 abdelaziz-mahdy

looks like sometimes the code is not waiting for the UI to link

what I tested

  1. Disabled window manager 1.1 sometimes the first launch failed then the rest is good 1.2 sometimes everything is working perfectly
  2. Having window manager enabled and going to full screen 99% of local files fail while network 99% succedes

so when using window manager 99% it doesn't link and gives a black screen

and playing network files gives the code the time to link since it takes a time to start the network video

abdelaziz-mahdy avatar May 16 '22 11:05 abdelaziz-mahdy

any news?

abdelaziz-mahdy avatar May 29 '22 14:05 abdelaziz-mahdy

[macOs] Same issue :(

LarYoungruu avatar Jun 22 '22 06:06 LarYoungruu

same issue here. =( but i saw this code in another topic and worked:

ListView( shrinkWrap: true, children: [ NativeVideo( player: _videoPlayer, height: 420.0, width: 360.0, ), ], ),

PauloBTX avatar Jul 19 '22 23:07 PauloBTX

In my case the screen is white. image

sadikul1500 avatar Oct 10 '22 08:10 sadikul1500

Hi, I have decided to remove NativeVideo widget for now in the latest version v0.4.0. Since it is no more, this is no longer a concern. Below I have discussed the future plans:

First of all, sorry for being inactive. I've been occupied with my exams & college. Maintaining open-source packages requires consistent work & time out of daily life. Writing C++ & native code is even more tedious.

There are a number of issues with this package, both in regard of performance & stability which I would like to fix. I'm not quite satisfied with the current state of the package, though I believe it is still usable. Hardware acceleration is a big concern. Currently, a substantial amount of load is caused on the CPU when using package:dart_vlc. This is because every video frame is copied from GPU to RAM buffer (which is a CPU process & CPU isn't made for rendering) for drawing it into Flutter's texture widget, both due to Flutter & libvlc's limitations at that time.

I made NativeVideo widget for bringing hardware-acceleration but as it turns out, it is not exactly good & stable alternative i.e. it uses undocumented API from Windows, has other issues while rendering inside widget tree (like you shared). It simply worked by creating another window under actual Flutter window & making a section of Flutter app transparent to display video through it. Thus, a hacky solution.

Now, my work is sponsored by Stream. I can now proceed my work with peace & build the best-ever performant & stable video library for Flutter Desktop. I attempted to render using OpenGL the other day: flutter-windows-ANGLE-OpenGL-Direct3D-Interop. I will continue this work.

Thanks!

alexmercerind avatar Dec 01 '22 02:12 alexmercerind