alexmercerind / dart_vlc

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

flutter native view all black (when playing local file) #275

Closed abdelaziz-mahdy closed 1 year ago

abdelaziz-mahdy commented 2 years ago

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:

Other details:

Screenshots image

alexmercerind commented 2 years ago

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.

abdelaziz-mahdy commented 2 years ago

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 commented 2 years ago

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

abdelaziz-mahdy commented 2 years ago

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 commented 2 years ago

any news?

LarYoungruu commented 2 years ago

[macOs] Same issue :(

PauloBTX commented 2 years ago

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, ), ], ),

sadikul1500 commented 2 years ago

In my case the screen is white. image

alexmercerind commented 1 year ago

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!