video_player_win icon indicating copy to clipboard operation
video_player_win copied to clipboard

Video sometimes don't play when starting more than one video at once

Open hillelcoren opened this issue 1 year ago • 15 comments

Hi,

Thanks for the excellent package!

We've run into an issue when showing multiple video players on the screen at once, the setVolume function only affects the last video added.

hillelcoren avatar Mar 16 '23 18:03 hillelcoren

Hi, From video_player_win version 2.2.0, setVolume() only affects the specified VideoPlayerController. ( before 2.2.0, setVolume() affects all the other videos, but that's a bug, and fixed in 2.2.0 )

If you want to set all the volumes of video players, you need to set one by one.

jakky1 avatar Mar 17 '23 05:03 jakky1

Thanks for the info, sorry for not first checking I was using the latest version.

It looks like I'm having trouble getting the app compile when using the latest version alongside the video_player_macos package.

Resolving dependencies... Because every version of video_player_macos depends on video_player_platform_interface ^5.1.1 and video_player_win >=1.1.6 depends on video_player_platform_interface ^6.0.1, video_player_macos is incompatible with video_player_win >=1.1.6. So, because mudeo depends on both video_player_win ^2.2.0 and video_player_macos any, version solving failed.

I'll follow up with the video_player_macos package.

hillelcoren avatar Mar 17 '23 05:03 hillelcoren

I found this issue: https://github.com/ollyde/flutter_macos_video_player/issues/14

Changing our pubspec to the following enabled it compile with the latest version:

video_player: ^2.5.3
video_player_win: ^2.2.0
video_player_macos:
  git:
    url: https://github.com/ollyde/flutter_macos_video_player.git
    path: packages/video_player/video_player_macos

However it seem like it's now actually worse. Before the videos would always play but there was the problem with setVolume whereas now many videos aren't able to play and no videos have sound. Any ideas?

hillelcoren avatar Mar 17 '23 05:03 hillelcoren

On which OS the issues you mentioned occurs?

If it occurs in Windows, could you please describe more details? If it occurs in MacOS, since I have no Mac devices, so please contact the video_player_macos package owner.

jakky1 avatar Mar 17 '23 07:03 jakky1

The issues affect the Windows version of the app. I've tried completely removing the video_player_macos package from the app and I'm still seeing problems.

Between the old version and the new versions some things have improved and other things have degraded. The rotation of the videos seems to more correct however the videos aren't auto-playing correctly and I don't hear any sound. If you're up for trying out my app it can be downloaded here: http://github.com/hillelcoren/mudeo

I noticed on the readme info about codecs. With the older version of the package the videos worked without adding any codecs, is it possible with the new version the codecs are now required?

Thanks for your help!

hillelcoren avatar Mar 17 '23 08:03 hillelcoren

After video_player_win 2.2.0 (or 2.0.0), yes sometimes video doesn't play if you start more than 2 videos simultaneously.

It is really a bug. However, I'm focus on other project now, and I have no time to fix this in a short time :( I'll try to fix it if I have time

Temp solution:

  1. reload video manually if user see the video not play... XD
  2. don't load videos at the same time, maybe with about 300ms~1000ms interval (I have not test on it)
  3. rollback to video_player_win: 1.1.6, however the CPU usage may be high, depends on what you played and how many video you played simultaneously

jakky1 avatar Mar 17 '23 08:03 jakky1

That probably explains it, the app is a multi-track video player/recorder so many videos are playing at once.

I'll update the issue title, thanks again!

hillelcoren avatar Mar 17 '23 08:03 hillelcoren

One thought, is it worth adding a parameter to optionally disable hardware acceleration until it's more stable?

hillelcoren avatar Mar 17 '23 14:03 hillelcoren

Fixed. Only push to github

dependencies:
  video_player_win:
    git:
      url: https://github.com/jakky1/video_player_win.git
      ref: master

However, sometimes (3%, only occurs when open multiple videos at once) video not auto play (only display first frame), can be recovered by calling pause()/play()

jakky1 avatar Mar 18 '23 08:03 jakky1

It's a massive improvement, thank you!!

3% would be fine but I'm seeing closer to 30% black screens. Calling stop/play does fix it though so there is a workaround when it happens.

        _playVideos();
        if (Platform.isWindows) {
          WidgetsBinding.instance.addPostFrameCallback((_) async {
            _pauseVideos();
            WidgetsBinding.instance.addPostFrameCallback((_) async {
              _playVideos();
            });
          });
        }

hillelcoren avatar Mar 18 '23 18:03 hillelcoren

I think I found the root cause about video freeze (maybe) I tried to open 100 times with each time open two 720p videos at the same time, and no video freeze at the beginning of 3 seconds.

I push to github only. Please try it and
remember to @flutter pub get@ to pull the latest version from github, and mark the temp solution you mentioned above first.

Hope this solution also works in your environment.

jakky1 avatar Mar 19 '23 12:03 jakky1

There may be a small improvement however the app still works much better if I include the code above to start/stop/start the videos. Thanks again for your help with this!

hillelcoren avatar Mar 19 '23 13:03 hillelcoren

Hi, I just push video_player_win: ^2.2.2 to pub.dev and maybe this version solve this issue.

I'll close this issue if no response in 7 days.

jakky1 avatar Mar 22 '23 11:03 jakky1

Thanks! I'll give it a try...

hillelcoren avatar Mar 22 '23 11:03 hillelcoren

It keeps improving but I'm still seeing some errors. Note: in some cases our app can play up to 5 videos at once.

hillelcoren avatar Mar 22 '23 12:03 hillelcoren