导航栏抖动时暂停视频播放器

问题描述

我正在制作Tiktok克隆应用

我正在使用IndexedStack来实现这一点。

一切都很好,但是有一个问题

我不知道如何暂停

这是HomeScreen()

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) async {
    print('didChangeAppLifecycleState CALLED ✅');
    if (state != AppLifecycleState.resumed) {
      _videoListController.currentPlayer.pause();
    }
  }

这是navigationBar代码

  @override
  Widget build(BuildContext context) {

    _widgetoptions = <Widget>[
      HomeScreen(),// Video is here ✅
      SearchScreen(),ProductScreen(),ProfileScreen(),];

    return Scaffold(
      body: IndexedStack(index: _selectedindex,children: _widgetoptions),bottomNavigationBar: Container(
        decoration: Boxdecoration(color: Colors.white,BoxShadow: [
          BoxShadow(
            blurRadius: 20,color: Colors.black.withOpacity(.1),),]),...

在HomeScreen()中 更改导航索引时未调用didChangeAppLifecycleState 因此,玩家不会自动停止

我该如何解决??

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)