befovy / fijkplayer

ijkplayer for flutter. ijkplayer 的 flutter 封装。 Flutter video/audio player. Flutter media player plugin for android/iOS based on ijkplayer. fijkplayer 是基于 ijkplayer 封装的 flutter 媒体播放器,开箱即用,无需编译 ijkplayer
https://fijkplayer.befovy.com
MIT License
1.65k stars 354 forks source link

[BUG]使用PageView组件滑动时视频会出现闪动 #623

Open WenjieZhengJerry opened 10 months ago

WenjieZhengJerry commented 10 months ago

Describe the bug 使用flutter官方组件PageView滑动Page时视频会出现闪动,闪动的画面是下一个Page的视频画面,详情请看录屏

What attempts have you made to resolve this error ? 给FijkView添加了GlobalKey然而并不起作用

To Reproduce 问题的复现步骤

  1. 滑动时使当前视频到达屏幕顶部,当视频被tabbar遮挡时会出现闪动
  2. 来回滑动必定触发
  3. 除了上下滑动之外,左右滑动也会触发,只是触发概率没有上下滑动高

Expected behavior 上下滑动时不出现闪动

Screenshots 录屏路径:https://github.com/befovy/fijkplayer/assets/43103543/253d0ad3-fa1a-48b4-a9b9-62564fa7bd66

fijkplayer version fijkplayer: 0.11.0

Smartphone (please complete the following information): Android Studio模拟器:Pixel 7 Pro API 34

Additional context 下面是我的代码:


class ScrollPlayer extends StatefulWidget {
  const ScrollPlayer({super.key});

  @override
  State<ScrollPlayer> createState() => _ScrollPlayerState();
}

class _ScrollPlayerState extends State<ScrollPlayer> {
  final List<(FijkPlayer, GlobalKey)> playerList = [(FijkPlayer(), GlobalKey()),(FijkPlayer(), GlobalKey())];

  @override
  void initState() {
    super.initState();
    playerList[0].$1.setDataSource('https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4', showCover: true);
    playerList[1].$1.setDataSource('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', showCover: true);
  }

  @override
  Widget build(BuildContext context) {
    return PageView.builder(
      scrollDirection: Axis.vertical,
      itemCount: playerList.length,
      itemBuilder: (BuildContext context, int index) {
        return _buildItem(playerList[index].$1, playerList[index].$2);
      },
    );
  }

  Widget _buildItem(FijkPlayer player, GlobalKey globalKey) {
    return Container(key: globalKey, child: FijkView(player: player));
  }
}
caisimai commented 8 months ago

同样情况,您解决了吗?

WenjieZhengJerry commented 8 months ago

同样情况,您解决了吗?

没解决,不知道什么问题。

CYscared commented 3 months ago

我也碰到了,我pageview开启allowImplicitScrolling属性就发现了这个问题。然后我是纵向pageview发现的,然后改成横向的发现100%出现,纵向还好,偶现。

OnClickListener2048 commented 1 week ago

up